Views:

Description

Returns a string which is the 'string' but replaces all regex matches of 'regextofind' with 'regextoreplace'.

Signature

RegexReplace('string', «regextofind», «regextoreplace»)

Example 1

RegexReplace('0123456789', «(\d{3})(\d{3})(\d{4})», «($1) $2-$3») 
Returns (012) 345 6789

Example 2

Removes all digits from a string

RegexReplace('stringinput', «\d», '')

Example 3

Removes all characters from a string to only leave digits

RegexReplace('stringinput', «\D», '')

Example 4

Removes duplicate white space (tabs, newlines, spaces, etc,) from a string

RegexReplace('stringinput', «\s+», ' ')

Example 5

Removes all ascii characters from a string

RegexReplace('stringinput', «[^\u0000-\u007F]», '')

Example 6

Removes all ascii characters and ascii control characters from a string

RegexReplace('stringinput', «[^\u0020-\u007F]», '')

Example 7

Removes everything except alpahnumeric ascii characters from a string

RegexReplace('stringinput', «[^A-Za-z0-9]», '')

Example 8

Removes all non-alphanumeric charcters except @, - (a dash), . (a period)

RegexReplace('stringinput', «[^\w\.@-]», '')

Example 9

Formats a US telephone number

RegexReplace('US telephone number',
  «(\d{3})(\d{3})(\d{4})», «($1) $2-$3»
)

Example 10

Formats a US telephone number with extensions

RegexReplace('US telephone number', 
  «^\D*(\d)\D*(\d)\D*(\d)\D*(\d)\D*(\d)\D*(\d)\D*(\d)\D*(\d)\D*(\d)\D*(\d)\D*(\d{2,})$»,
  «+1 ($1$2$3) $4$5$6-$7$8$9$10 Ext $11»
)

Parameters

Name Type Description Required
string xxxx xxxx xxxx
«regextofind» xxxx xxxx xxxx
«regextoreplace» xxxx xxxx xxxx