Finds the first occurrence of any one of a set of characters in a string, from a specified start position. The search is case-sensitive.
Returns the position of the first member of set found in string; or 0, if no member of set is found in string.
findOneOf(set, string [, start])
→ returns numeric
1
We're not passing a start index in this example.
string_to_search = 'The rain in Spain falls mainly in the plains.';
writeOutput( findOneOf('in', string_to_search) );
Expected Result: 7
Let's pass in a starting index of 12. The search will start at the twelfth character, just before the word 'Spain'.
string_to_search = 'The rain in Spain falls mainly in the plains.';
writeOutput( findOneOf('in', string_to_search, 12) );
Expected Result: 16
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.
string_to_search = 'The rain in Spain falls mainly in the plains.';
writeOutput( findOneOf('tHe', string_to_search, 1) );
Expected Result: 3
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.