Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
April 13–15 - Dare to Unleash a New Professional You at Qlik Connect 2026: Register Now!
Ouadie
Employee
Employee

Regex has been one of the most requested features in Qlik Sense for years, and now it’s finally here.

With this year's May 2025 release, Qlik added native support for regular expressions in both load scripts and chart expressions. That means you can validate formats, extract values, clean up messy text, and more, all without complex string logic or external preprocessing.

In this post, we’ll look at what’s new, how it compares to the old workarounds, and a practical example you can plug into your own app.

The New Regex Functions

Regex (short for Regular Expression) is a compact way to define text patterns. If you’ve used it in Python, JavaScript, or other programming languages, the concept will feel familiar.

Qlik now includes native support for regular expressions with functions that work in load scripts and chart expressions:

  • MatchRegEx() – check if a value matches a pattern

  • ExtractRegEx() – extract the first substring that matches

  • ReplaceRegEx() – search and replace based on a pattern

  • SubFieldRegEx() – split text using regex as the delimiter

There are also group-based versions (ExtractRegExGroup, etc.), case-insensitive variants (MatchRegExI), and helpers like CountRegEx() and IsRegEx().

🔗 Help Article

Replacing Old Patterns

Here's where regex saves time:

  • Format validation: Replace nested Len(), Left(), and Mid() with a single pattern.

  • Substring extraction: Skip the manual slicing; let the pattern do the work.

  • Pattern-based replacements: Clean or reformat values without chaining multiple functions.

 

With regex:

If(MatchRegEx(Code, '^[A-Z]{2}-\d{5}$'), 'Valid', 'Invalid')  // check format

ExtractRegEx(Text, '\d{5}')                                   // get first 5-digit number

ReplaceRegEx(Field, '\D', '')                                 // strip non-digits

Cleaner logic. Fewer steps. Easier to maintain.

Use Cases That Just Got Easier

If any of the following sound familiar, regex will help:

  • Format checks: postal codes, product SKUs, ID numbers.

  • Data extraction: get domain from email, number from notes, etc.

  • PII masking: hide parts of a SSN or credit card.

  • String cleanup: strip unwanted characters, normalize spacing.

  • Splitting tricky fields: CSV lines with quoted commas, mixed delimiters.

Keep in mind that these functions can be used directly in chart expression, so you can build visuals or filters based on pattern logic, not just static values.


Example: Clean and Validate Phone Numbers

Let’s say you’ve got a bunch of phone numbers like this:

(312) 678-4412  
312-678-4412  
3126784412  
123-678-4412    // invalid: area code starts with 1  
312-045-4412    // invalid: exchange starts with 0  
312-678-441     // invalid: too short  

 

You want to:

  1. Validate that it’s a proper 10-digit North American number

  2. Standardize the format to (###) ###-####

Here’s how to do it with regex in your load script:

LOAD
    RawPhone,

    // 1. Strip out anything that's not a digit
    ReplaceRegEx(RawPhone, '\D', '') as DigitsOnly,

    // 2. Validate: 10 digits exactly, starting with 2–9
    If(MatchRegEx(RawPhone, '^\(?[2-9]\d{2}\)?[-.\s]?\d{3}[-.\s]?\d{4}$'),
        'Valid', 'Invalid') as Status,

    // 3. Standardize format to (###) ###-####
    ReplaceRegEx(
        ReplaceRegEx(RawPhone, '\D', ''), 
        '(\d{3})(\d{3})(\d{4})', 
        '(\1) \2-\3'
    ) as FormattedPhone

INLINE [
    RawPhone
    3025557890
    (404) 222-8800
    678.333.1010
    213 888 9999
    1035559999
    678-00-0000
    55577
];

 

Result:

 

Ouadie_2-1763765573831.png

One pattern replaces multiple conditions and formatting is consistent. This is much easier to maintain and easy to expand if the rules change.


Final Thoughts

  • Use regex where it adds value.
    For simple cases like Left() or Trim(), stick with built-in string functions.

  • When you're working with inconsistent inputs, embedded formats, or anything that doesn’t follow clean rules, regex can save a lot of time.

  • If you're applying regex across large datasets, especially in charts, it’s better to handle it in the load script where possible.

Not sure how to write the pattern?

Tools like regex101.com or regexr.com are great for testing and adjusting before you build in Qlik.

 

With native regex in Qlik Sense, you can now clean, validate, extract, and transform text with precision without convoluted scripts or third-party tools. It’s a quiet but powerful upgrade that unlocks a ton of flexibility for real-world data.

2 Comments