SubFieldRegEx - script and chart function
SubFieldRegEx() extracts text from an input string expression, using the specified regular expression pattern as a delimiter. The function returns a null value if no matches are found.
This function performs regex operations that are case-sensitive. You can alternatively use the variant SubFieldRegExI() to perform case-insensitive regex operations.
Syntax:
SubFieldRegEx (text, regex_delimiter [, field_no])
Return data type: string
Argument | Description |
---|---|
text | The input string text within which you want to search for a regular expression pattern. |
regex_delimiter | String expression containing the regular expression to use as a delimiter. You can specify more than one delimiter in the same regular expression pattern by separating them with a | (vertical pipe) character. |
field_no |
Integer value indicating the number of the subdivision you want to extract. For example, specify a value of 4 to extract the fourth subdivision. This is an optional argument. The following apply regardless of whether the function is used in a load script or chart expression:
When using the function in a load script:
When using the function in a chart expression:
|
Example | Result |
---|---|
SubFieldRegEx('a,b c;1 2,3',' |,|;', 1) | Returns a. In this example, three delimiter characters are specified (space, comma, and semicolon). |
SubFieldRegEx('a;b;c;1;2;3',';', 2) | Returns b. In this case, only one delimiter character is specified (semicolon). |
SubFieldRegEx('a,b c;1 2,3',' |,|;', 4) | Returns 1. |
When to use it
You can use SubFieldRegEx() to extract multiple individual values from a delimited list. For example, if you have a comma-separated list contained within a larger block of natural language, you can use this function to isolate each individual value from the list into a new record in your data model.