index expression function

Finds the first occurrence of a pattern in a string.

All Usage Examples

See also: rindex

Usage

index(source, pattern)

Returns the number of characters before pattern occurs in source. Returns -1 if the pattern is not found.

Examples

echo `index("Testing index", "sting")`

Prints 2

echo `index("Testing index", "i")`

Prints 4