Skip to main content

Regular Expressions


r”<escaped regex syntax>”r”\\w+”Match a word. Note the \ to escape the .
r”“”<unescaped regex syntax>”“”r”“”\w+”“”Match a word. No need to escape \ since inside triple quotes.

Syntax Regular expression constructs are:

\WNot a word.
\SNot a space.
\DNot a digit.
.Match any character.
<regex>*Match any number of times.
<regex>?Match or not.
<regex>+Match any number of times but at least once.
<regex>{<n>}Repeat n times.
^Begin of line.
$End of line.
[<x>-<y>]Interval from x to y.
<regex> I <regex>Or.


NOTE: PARSE AS and INTO are often used together as in:

FROM text_file PARSE AS r"""(\w+)\s+(\d+)"""
INTO (first: _1, second: CAST(_2 AS int))

This parses a text_file into an unnamed record with two elements, which is then converted into a named record with field second of type int.