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

MatchRegEx - script and chart function

MatchRegEx() compares the input string with one or more specified regular expression patterns, and returns the numeric location of the regular expression patterns that match. If no matches are found, the function returns 0. This function looks for exact matches only.

This function performs regex operations that are case-sensitive. You can alternatively use the variant MatchRegExI() to perform case-insensitive regex operations.

Syntax:  

MatchRegEx (text, regex1 [ , regex2,...regexN])

Return data type: integer

Arguments
Argument Description
text The input string text to which you want to match one or more regular expressions.
regex The regular expression to try to match to the input string. You can specify more than one regular expression in a single expression, separated as subsequent arguments.
Function examples
Example Result
MatchRegEx('abc123','[a-z]','[0-9]','[a-z]+[0-9]+','.+') Returns 3 .The third regex pattern is the first to match the data.
MatchRegEx('ABC','[abc]+','[123]') Returns 0, because MatchRegEx() is case-sensitive.
MatchRegExI('ABC','[abc]+','[123]') Returns 1 .The case-insensitive variant of the function, MatchRegExI(), is used.

When to use it

Use cases for this function include:

  • Validating text to meet formatting and compliance standards, and to identify errors in data.

  • Identifying differences in how text is formatted. For example, you can identify how many phone numbers use format A, format B, and so on.

Example 1 – load script to analyze phone number formats

Example 2 – chart expression to identify ISBN format

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!