Core Function LastIndexOfAny
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> LastIndexOfAny( <expression>, <needle>, <pos>, <case>, <count> ) </pre> === Description === Reports the index of the last occurrence of any characters or array of strings...") |
m (1 revision) |
||
(2 intermediate revisions by one user not shown) | |||
Line 54: | Line 54: | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
+ | // Find characters | ||
+ | println( IndexNotOfAny("The quick brown FoX", "ehT") ); | ||
// Find from a string | // Find from a string | ||
println( LastIndexOfAny("The quick brown FoX", array("FoX")) ); | println( LastIndexOfAny("The quick brown FoX", array("FoX")) ); | ||
Line 63: | Line 65: | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
+ | // Find characters | ||
+ | println( IndexNotOfAny("The quick brown FoX", "eht", 0, true) ); | ||
// Find from a string | // Find from a string | ||
my $str = "The quick brown FoX"; | my $str = "The quick brown FoX"; |
Latest revision as of 12:37, 14 June 2015
LastIndexOfAny( <expression>, <needle>, <pos>, <case>, <count> )
Contents |
Description
Reports the index of the last occurrence of any characters or array of strings in a specified string.
Parameters specify the starting search position in the current string and the type of search to use for the specified string.
expression
The string to use.
needle
The characters to find (as a string) or an array of strings to find.
pos
Optional; Position to start the search from within the expression.
Default: expression length - 1
case
Optional; Case sensitive option
false = Case sensitive search
true = Case insensitive search
Default: false
count
Optional; The amount of characters to check before quitting the search
Default: pos + 1
Return Value
Success: Returns last position of the found character or string in the string.
Failure: Returns -1.
Remarks
None.
Example
Case sensitive
// Find characters println( IndexNotOfAny("The quick brown FoX", "ehT") ); // Find from a string println( LastIndexOfAny("The quick brown FoX", array("FoX")) ); // Find from an array of strings println( LastIndexOfAny("The quick brown catFoX", array("Fox", "cat")) );
Case insensitive
// Find characters println( IndexNotOfAny("The quick brown FoX", "eht", 0, true) ); // Find from a string my $str = "The quick brown FoX"; println( LastIndexOfAny($str, array("foX"), strlen($str) - 1, true) ); // Find from an array of strings my $str = "The quick brown catFoX"; println( LastIndexOfAny("The quick brown catFoX", array("Fox", "cat"), strlen($str) -1, true) );