Early Access: The content on this website is provided for informational purposes only in connection with pre-General Availability Qlik Products.
All content is subject to change and is provided without warranty.
Skip to main content Skip to complementary content

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

Arguments
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:

  • If field_no is positive, the function will return one value, identifying matches from left to right.

  • If field_no is negative, the function will return one value, identifying matches from right to left.

When using the function in a load script:

  • If you use the SubFieldRegEx() function in a LOAD statement and field_no is omitted, the function generates as many records as there are matches.

  • If several fields are loaded using SubFieldRegEx() and none of them specify a field_no argument, the Cartesian products of all combinations are created.

When using the function in a chart expression:

  • If the field_no is omitted, the default value is 1.

Function examples
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.

Example 1 – load script to separate tags by transaction

Example 2 – chart expressions to separate tags by transaction

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!