Core Function IndexOfAny
From Sputnik Wiki
IndexOfAny( <expression>, <needle>, <pos>, <case>, <count> )
Contents |
Description
Reports the index of the first occurrence of any characters or array of strings in a 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: 0
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: expression length - pos
Return Value
Success: Returns position of the found character or string in the string.
Failure: Returns -1.
Remarks
None.
Example
Case sensitive
// Find characters println( IndexOfAny("The quick brown FoX", "qki") ); println( IndexOfAny("The quick brown FoX", "qkie") ); // Find string println( IndexOfAny("The quick brown FoX", array("FoX")) ); // Find array of strings println( IndexOfAny("The quick brown FoX", array("brown", "FoX")) );
Case insensitive
// Find characters println( IndexOfAny("The quick brown FoX", "QK", 0, true) ); println( IndexOfAny("The quick brown FoX", "EQ", 0, true) ); // Find string println( IndexOfAny("The quick brown FoX", array("fox"), 0, true) ); // Find array of strings println( IndexOfAny("The quick brown FoX", array("brown1", "fox"), 0, true) );