Use Regular Expressions
On this page: A how-to guide to using regular expressions with WOQL and JavaScript.
WOQL provides Pearl Compatible Regular Expressions (PCRE) using the predicate regexp with the structure:
1
regexp(pattern, string, match_list)
Copied!

Regular expressions examples

Examples of basic regular expression pattern matching with WOQL.

Match a string in sub position 1

Match a string to pattern "t(..)t".

Code: String match sub position 1

1
regexp("t(..)t", "test", ["v:All", "v:Match"])
Copied!
Results
v:All
v:Match
"test"
"es"

Match a string in sub position 2

Match a string to pattern "m..h".

Code: String match sub position 2

1
regexp("m...h", "this is a match of a string", ["v:All"])
Copied!
Results
v:All
"match"

Match start and end of a string

Match start ^ and end $ of a string to pattern "^m...hquot;.

Code: String match start and end

1
regexp("^m...h$", "this is a match of a string", ["v:All"])
2
3
regexp("^m...h$", "match", ["v:All"])
Copied!
Results
v:All
(no match)
"match"

Match multiple parts of a string

Match start and end of the string to pattern "^(....)-(..)-(..)quot;.

Code: String match multiple parts

1
regexp("^(....)-(..)-(..)$", "2020-10-12", ["v:All", "v:Year", "v:Month", "v:Day"])
Copied!
Results
v:All
v:Year
v:Month
v:Day
"2020-10-12"
"2020"
"10"
"12"