跳到主要內容 跳至補充內容

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}, '(?:.+\/)(.+)'}

此頁面是否對您有幫助?

若您發現此頁面或其內容有任何問題——錯字、遺漏步驟或技術錯誤——請告知我們可以如何改善!