ajRegExpCount function
Description
The ajRegExpCount function counts the number of times that a pattern occurs in a string using regular expression.
Syntax
ajRegExpCount(input_string, pattern, [start_position], [ignore_case], [multi_line])
Argument Name | Argument Type | Description |
---|---|---|
input_string (required) | Range / Array | The range of cells to be set as the message to be searched. The range of cells can span across multiple rows and columns and it will be concatenated into a single string. It will concatenate the row first follow by the column. For example, Cell A1, “Hello” Cell A2, “You” Cell B1, “I” Cell B2, “Good” Concatenated result => “HelloIYouGood” |
pattern (required) | String | The regular expression to match. It follows the Basic Regular Expressions (BRE) of the IEEE POSIX standard. |
start_position (optional) | Double | The starting search position of ‘Input_string’. 1 is the first position. It will begin from the first position by default. |
ignore_case (optional) | Boolean | TRUE for case insensitive search. FALSE for case sensitive search. The default value is FALSE. |
multi_line (optional) | Boolean | If it equals TRUE, and ‘Input_string’ has newline or carriage return characters, the ^ and $ operators will match against a newline boundary. If it equals FALSE, and ‘Input_string’ has newline or carriage return characters, the ^ and $ operators will match against a string boundary. The default value is FALSE. |
The function will return:
1) Return Value: Matched regular expression count
2) Return Type: Single Value
Example
The regular expression below searches for a pattern that fulfills the following condition:
- the first and the second characters can be any character.
- the third character must be an alphabet.
- the fourth character must be "o"
- the fifth character must be an alphabet.
- the sixth and seventh characters can be any character.
3 matches were found in the input string.
Click here to download the use case workbooks for further reference.
Error Scenarios
It will return #VALUE! when missing any required parameter or mismatch parameter type.