Centrldesk help center

Match a text against a regular expression in Centrldesk

Written by Sebastian | Mar 30, 2022 1:51:56 PM

The Text Matches block is used to match a text against a regular expression.

A regular expression or regex is a sequence of characters that specifies a search pattern in text. If the text matches the regex to be checked, it evaluates to true. If not, false is returned.

Example A:

Using the input Expression 'gray|grey' for input texts 'The color is gray' and 'The color is grey' true is returned.

Example B:

Using the input Expression 'b[aeiou]bble' for the input texts 'babble', 'bebble', 'bibble', 'bobble' and 'bubble' true is returned.

Result:

True or false depending on whether the text matches the expression.

Tips and best practices:

List of regular expression examples:

Regex Matches any string that
hello contains {hello}
gray|grey contains {gray, grey}
gr(a|e)y contains {gray, grey}
gr[ae]y contains {gray, grey}
b[aeiou]bble contains {babble, bebble, bibble, bobble, bubble}
[b-chm-pP]at|ot contains {bat, cat, hat, mat, nat, oat, pat, Pat, ot}
colou?r contains {color, colour}
rege(x(es)?|xps?) contains {regex, regexes, regexp, regexps}
go*gle contains {ggle, gogle, google, gooogle, goooogle, ...}
go+gle contains {gogle, google, gooogle, goooogle, ...}
g(oog)+le contains {google, googoogle, googoogoogle, googoogoogoogle, ...}
z{3} contains {zzz}
z{3,6} contains {zzz, zzzz, zzzzz, zzzzzz}
z{3,} contains {zzz, zzzz, zzzzz, zzzzzz}
z{3,} contains {zzz, zzzz, zzzzz, ...}
\d contains {0,1,2,3,4,5,6,7,8,9}
\d{5}(-\d{4})? contains a United States zip code
1\d{10} contains an 11-digit string starting with a 1
[2-9]|[12]\d|3[0-6] contains an integer in the range 2..36 inclusive
^cat begins with "cat"
cat$ ends with "cat"
^cat$ is exactly "cat"

Library:

Text