regexCount

Syntax

regexCount(str, pattern, [offset=0])

Details

Return an integer indicating how many times pattern (a string or a regular expression pattern) occurs in str (a string).

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 count operation. The first character in str corresponds to position 0.

Examples

$ regexCount("FB IBM FB IBM AMZN", `IBM);
2

$ regexCount("FB IBM FB IBM AMZN", `IBM, 7);
1

$ regexCount("FB IBM FB IBM AMZN", `AAPL);
0