/
strFind
strFind
Description
Tries to find a sub-string within another string, and returns the zero-based index of the first character of the sub-string in string. If the sub-string is not found, -1 is returned.
Functional area
String
Command syntax
Syntax
strFind "string" "subString" index |
Arguments
Name | Type | Required | Comments |
---|---|---|---|
string | string | yes | String to be searched. |
subString | string | yes | Sub-string to be searched for with "string" argument. |
startIndex | integer | yes | Zero-based index of the character of string to start searching at, or 0 to search from the beginning. |
Flags
None
Return value
integer
Returns the zero based index of the location of the first character of the sub-string found. Returns -1 if not found.
Examples
// Search for a substring string $str = "This is some text"; int $index; // Search for the word "some" $index = `strFind $str "some" 0`; print $index; // Should be 8 // Search for the word "texas" $index = `strFind $str "texas" 0`; print $index; // Should be -1 // Search for the letter "t" after the word "some" $index = `strFind $str "t" 12`; print $index; // Should be 13
Additional information
Related commands
, multiple selections available,
Related content
strMid
More like this
strLeft
strLeft
More like this
strReplace
strReplace
More like this
strTokArray
strTokArray
More like this
seekToString
seekToString
More like this
readWord
readWord
More like this