Zu Hauptinhalt springen Zu ergänzendem Inhalt springen

Working with regular expressions

Regular expression can be used with the regex functions. This section contains example of some useful expressions.

General expressions

This example removes special characters from a string. Special characters are everything that is not a-z or 1-9.

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

This example removes special characters from a string but keeps characters with accents.

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

This example replaces a special character—the German "ß"—with a double "s".

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

Names

These examples parse the first and last name from a full name, where the name format is "FirstName" "LastName".

Get first name:

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

Get last name:

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

Addresses

This example parses the house number from a street address, where the format is "StreetName" "HouseNumber".

Get the house number:

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

Phone numbers

This example removes all special characters from a phone number.

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

URLs and domain names

This example parses the path from a full URL, where the URL has a .com domain.

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

Get the filename part of a URL:

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

Hat diese Seite Ihnen geholfen?

Wenn Sie Probleme mit dieser Seite oder ihren Inhalten feststellen – einen Tippfehler, einen fehlenden Schritt oder einen technischen Fehler –, teilen Sie uns bitte mit, wie wir uns verbessern können!