View source code
							
							
						
								Display the source code in std/string.d from which this
								page was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create a
								Bugzilla issue.
							
						
							
								Improve this page
							
							
					
								Quickly fork, edit online, and submit a pull request for this page.
								Requires a signed-in GitHub account. This works well for small changes.
								If you'd like to make larger changes you may want to consider using
								local clone.
							
						Function std.string.stripLeft
Strips leading whitespace (as defined by isWhite) or
    as specified in the second argument.
						
				auto stripLeft(Range)
				(
				
				  Range input
				
				)
				
				if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && !isInfinite!Range && !isConvertibleToString!Range);
				
				
				auto stripLeft(Range, Char)
				(
				
				  Range input,
				
				  const(Char)[] chars
				
				)
				
				if ((isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) || isConvertibleToString!Range) && isSomeChar!Char);
						
					
				Parameters
| Name | Description | 
|---|---|
| input | string or forward range of characters | 
| chars | string of characters to be stripped | 
Returns
input stripped of leading whitespace or characters
    specified in the second argument.
Postconditions
input and the returned value
    will share the same tail (see sameTail).
See Also
Generic stripping on ranges: stripLeft
Example
import std .uni : lineSep, paraSep;
assert(stripLeft("     hello world     ") ==
       "hello world     ");
assert(stripLeft("\n\t\v\rhello world\n\t\v\r") ==
       "hello world\n\t\v\r");
assert(stripLeft(" \u2028hello world") ==
       "hello world");
assert(stripLeft("hello world") ==
       "hello world");
assert(stripLeft([lineSep] ~ "hello world" ~ lineSep) ==
       "hello world" ~ [lineSep]);
assert(stripLeft([paraSep] ~ "hello world" ~ paraSep) ==
       "hello world" ~ [paraSep]);
import std .array : array;
import std .utf : byChar;
assert(stripLeft("     hello world     "w .byChar) .array ==
       "hello world     ");
assert(stripLeft("     \u2022hello world     " .byChar) .array ==
       "\u2022hello world     ");
Example
assert(stripLeft("     hello world     ", " ") ==
       "hello world     ");
assert(stripLeft("xxxxxhello world     ", "x") ==
       "hello world     ");
assert(stripLeft("xxxyy    hello world     ", "xy ") ==
       "hello world     ");
Example
import std .array : array;
import std .utf : byChar, byWchar, byDchar;
assert(stripLeft("  xxxyy hello world     "w .byChar, "xy ") .array ==
       "hello world     ");
assert(stripLeft("\u2028\u2020hello world\u2028"w .byWchar,
                 "\u2028") .array == "\u2020hello world\u2028");
assert(stripLeft("\U00010001hello world"w .byWchar, " ") .array ==
       "\U00010001hello world"w);
assert(stripLeft("\U00010001 xyhello world"d .byDchar,
                 "\U00010001 xy") .array == "hello world"d);
writeln(stripLeft("\u2020hello"w, "\u2020"w)); // "hello"w
writeln(stripLeft("\U00010001hello"d, "\U00010001"d)); // "hello"d
writeln(stripLeft(" hello ", "")); // " hello "
Authors
Walter Bright, Andrei Alexandrescu, Jonathan M Davis, and David L. 'SpottedTiger' Davis
License
					Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.