regexFind

Syntax

regexFind(str, pattern, [offset])

Arguments

str is a string scalar or vector.

pattern is an ordinary string scalar or a regular expression pattern to be searched in str.

offset is a positive integer with default value of 0. This optional argument is the starting position in str to conduct the search operation. The first character in str corresponds to position 0.

Details

Search in a string for another string or a regular expression pattern and return an integer that indicates the beginning position of the first matched substring. If no substring matches, return -1.

Compared with function strpos, in regexFind we can search a regular expression pattern, and we can also specify the starting position to search.

Examples

$ regexFind("FB IBM FB IBM AMZN", `IBM);
3

$ regexFind("FB IBM FB IBM AMZN", `IBM, 7);
10

$ regexFind("FB IBM FB IBM AMZN", `AAPL);
-1