FindOneOf
Finds the first occurrence of any character in a set of characters, from a specified start position.
Method Signature
Arguments
set
string
true
The set of characters to search for the first occurrence of.
string
string
true
The string to search in.
start
integer
false
The position from which to start searching in the string. Default is 1.
1
Examples
Find first instance starting from beginning of string.
We're not passing a start index in this example.
Result: 7
Find first instance starting from the twelfth character.
Let's pass in a starting index of 12. The search will start at the twelfth character, just before the word 'Spain'.
Result: 16
Example showing this function will search all characters from the 'set' argument in the 'string' argument.
This function is case-sensitive so 't' does NOT match the first 'T'. It's the same for 'H' NOT matching the first 'h'. But 'e' matches the 'e' at the third position. Since this is the first match, this is the index that is returned.
Result: 3
Additional Examples
Related
Last updated
Was this helpful?