Skip to main content Skip to complementary content

Useful regular expressions

Regular expressions can be used in Qlik Application Automation for OEM using the regex formulas . Examples:

{ regexReplace: $.getCompany.URL, "[^\w\s-_]", "" }
{ regexParse: $.fullname, '^([^\s]*)' }

Below are some useful regular expressions for various use cases of data cleansing, data extraction, and data normalization.

General

Remove special characters from a text (everything that is not a-z or a number):

{ regexReplace: $.getCompany.URL, "[^\w\s-_]", "" }

Remove special characters from a text but keep characters with accents:

{ regex_replace: $.companyname, "[^A-Za-zÀ-ÖØ-öø-ÿ ]" , "" }

Replace German sz:

{ regex_replace: $.companyname , "ß" , "ss"}

Names

Parse first name or last name from a full name (assuming format Firstname Lastname):

Get first name: { regexparse:$.fullname, '^([^\s]*)' }
Get last name: { regexparse:$.fullname, '^[^\s]*\s(.*)' }

Addresses

Parse the house number from a street address (assuming format Streetname housenumber):

{regexparse: 'Grauwpoort 1A-5, 9000 Gent', '([0-9]+[^ ,\n]*)'}

The above result will be 1A-5.

Phone numbers

Remove all special characters from a phone number:

{regex_replace:$.phone , "([^\S]|[^0-9+])",""}

URL's and domain names

Get the path from a full URL (assuming a .com domain):

{ regexparse:$.getCompany.url, "\.com(.*)" }

Get the filename part of a URL:

{regexparse: {$.url}, '(?:.+\/)(.+)'}