Find the position of a substring within a text string.
int strfind <string:Text> <string:TextToFind> <int:StartAt>
Name | Type | Comment |
---|---|---|
Text | string | A text string. |
TextToFind | string | A substring, the position of which in Text is to be found. |
StartAt | int | The zero-based starting position in Text to begin looking for TextToFind. Default is 0. |
An integer containing the position of the start of TextToFind in Text. Position indices are zero based.
If TextToFind is not found in Text at or after the position given by StartAt, -1 is returned.
// find the position of "test" in "This is a test" (ans:10) echo <strfind "This is a test" "test" 0>
… the output of which is written to the event log by echo as:
10
strfind
is case sensitive. For a case-insensitive find, use strupper or strlower to convert both the Text and TextToFind arguments to either upper case or lower case.