Skip to main content

Regex Reference

Reference for regular expressions used in StackQL.

See also:
[REGEXP_LIKE] [REGEXP_SUBSTR] [REGEXP_REPLACE]


Supported syntax​

The following regular expression syntax is supported in StackQL:

ExpressionDescription
X*zero or more occurrences of X
X+one or more occurrences of X
X?zero or one occurrences of X
X{n}exactly n occurrences of X
X{n,}n or more occurrences of X
X{n,m}between n and m occurrences of X
(X)match X
X|YX or Y
^XX occurring at the beginning of the string
X$X occurring at the end of the string
.Match any single character, including a newline
\cCharacter c where c is one of \{}()[]|*+?.
\cC-language escapes for c in afnrtv. ex: \t or \n
[abc]Any single character from the set abc
[^abc]Any single character not in the set abc
[a-z]Any single character in the range a-z
[^a-z]Any single character not in the range a-z
\d, \w, \sA digit, a word character ([0-9A-Za-z_]), a whitespace character
\D, \W, \SAny character that is not a digit, not a word character, not a whitespace character
\bA word boundary

 
 
Patterns use RE2 syntax, as implemented by Go's regexp package. Backreferences (\1) and lookaround assertions are not supported: a pattern that uses them is rejected with an error.

A backslash in a StackQL string literal starts an escape sequence ('\n' is a newline), so a backslash that belongs to the regular expression is written twice: '\\d+' matches one or more digits and '[0-9]+\\.[0-9]+' matches a literal dot between digits.

For the full syntax, see RE2 syntax.