Text

Match a text against a regular expression using Text Matches block

Match a text against a regular expression in Centrldesk

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:

library-text-functions-matches-example-1-2

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

Example B:

library-text-functions-matches-example-2-2

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

Similar posts

Subscribe to our newsletter

Stay up to date on upcoming news and topics of creating web apps without code.