indexOf
indexOf, function
def const pure indexOf(source: text, pattern: text): number
Returns the zero-based index of the first occurrence of pattern in source,
or -1 if not found.
source: text to search.pattern: text to find.
Examples
source = "Hello World!"
table T = with
[| as Pattern |]
[| "o" |]
[| "!" |]
[| "Z" |]
T.Index = indexOf(source, T.Pattern)
show table "Index" with
T.Pattern
T.Index
This produces the following table:
| Pattern | Index |
|---|---|
| o | 4 |
| ! | 11 |
| Z | -1 |
Remarks
indexOf is often used with substr.