View source code
							
							
						
								Display the source code in std/string.d from which thispage was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create aBugzilla 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 usinglocal clone.
							
						Function std.string.lastIndexOfAny
Searches haystack for the last occurrence of any of the
    characters in needles.
						
				ptrdiff_t lastIndexOfAny(Char, Char2)(
				
  const(Char)[] haystack,
				
  const(Char2)[] needles,
				
				  in CaseSensitive cs = Yes .caseSensitive
				
				) pure @safe
				
				if (isSomeChar!Char && isSomeChar!Char2);
				
				
				ptrdiff_t lastIndexOfAny(Char, Char2)(
				
  const(Char)[] haystack,
				
  const(Char2)[] needles,
				
  in size_t stopIdx,
				
				  in CaseSensitive cs = Yes .caseSensitive
				
				) pure @safe
				
				if (isSomeChar!Char && isSomeChar!Char2);
						
					
				Parameters
| Name | Description | 
|---|---|
| haystack | string to search needles in | 
| needles |  characters to search for in haystack | 
| stopIdx |  index in haystack to stop searching at (exclusive); defaults
            to haystack | 
| cs |  specifies whether comparisons are case-sensitive
            (Yes) or not (No) | 
Returns
The index of the last occurrence of any of the characters of needles
        in haystack. If no character of needles is found or stopIdx is 0,
        then -1 is returned. If the parameters are not valid UTF, the result
        will still be in the range [-1 .. stopIdx], but will not be reliable
        otherwise.
Example
ptrdiff_t i = "helloWorld" .lastIndexOfAny("Wlo");
writeln(i); // 8
i = "Foo öäöllo world" .lastIndexOfAny("öF");
writeln(i); // 8
Example
import std .conv : to;
ptrdiff_t i = "helloWorld" .lastIndexOfAny("Wlo", 4);
writeln(i); // 3
i = "Foo öäöllo world" .lastIndexOfAny("öF", 3);
writeln(i); // 0
Authors
Walter Bright, Andrei Alexandrescu, Jonathan M Davis, and David L. 'SpottedTiger' Davis
License
					Copyright © 1999-2025 by the D Language Foundation | Page generated by ddox.