Core Function IndexOfAny
From Sputnik Wiki
(Difference between revisions)
m (1 revision) |
|||
(3 intermediate revisions by one user not shown) | |||
Line 39: | Line 39: | ||
=== Return Value === | === Return Value === | ||
− | Success: Returns position of the found character in the string. | + | Success: Returns position of the found character or string in the string. |
Failure: Returns -1. | Failure: Returns -1. | ||
Line 55: | Line 55: | ||
println( IndexOfAny("The quick brown FoX", "qki") ); | println( IndexOfAny("The quick brown FoX", "qki") ); | ||
println( IndexOfAny("The quick brown FoX", "qkie") ); | println( IndexOfAny("The quick brown FoX", "qkie") ); | ||
+ | // Find string | ||
+ | println( IndexOfAny("The quick brown FoX", array("FoX")) ); | ||
// Find array of strings | // Find array of strings | ||
println( IndexOfAny("The quick brown FoX", array("brown", "FoX")) ); | println( IndexOfAny("The quick brown FoX", array("brown", "FoX")) ); | ||
Line 65: | Line 67: | ||
println( IndexOfAny("The quick brown FoX", "QK", 0, true) ); | println( IndexOfAny("The quick brown FoX", "QK", 0, true) ); | ||
println( IndexOfAny("The quick brown FoX", "EQ", 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 | // Find array of strings | ||
println( IndexOfAny("The quick brown FoX", array("brown1", "fox"), 0, true) ); | println( IndexOfAny("The quick brown FoX", array("brown1", "fox"), 0, true) ); |
Latest revision as of 12:37, 14 June 2015
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) );