Use Regular Expressions
Use regular expressions with WOQL and JavaScript.
WOQL provides Pearl Compatible Regular Expressions (PCRE) using the predicate regexp with the structure:
regexp(pattern, string, match_list)

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

regexp("t(..)t", "test", ["v:All", "v:Match"])
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

regexp("m...h", "this is a match of a string", ["v:All"])
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

regexp("^m...h$", "this is a match of a string", ["v:All"])
regexp("^m...h$", "match", ["v:All"])
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

regexp("^(....)-(..)-(..)$", "2020-10-12", ["v:All", "v:Year", "v:Month", "v:Day"])
Results
v:All
v:Year
v:Month
v:Day
"2020-10-12"
"2020"
"10"
"12"
Export as PDF
Copy link
On this page
Regular expressions examples
Match a string in sub position 1
Match a string in sub position 2
Match start and end of a string
Match multiple parts of a string