Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

regexp

perform a regular expression search on a string

Synopsis

regexp(re: string, s: string) -> [string]

Description

The regexp function returns an array of strings holding the text of the left most match of the regular expression re, which is a regular expression, and the matches of each parenthesized subexpression (also known as capturing groups) if there are any. An empty array indicates no match.

Examples


Regexp returns an array of the match and its subexpressions

# spq
values regexp(r'foo(.?) (\w+) fr.*', this)
# input
"seafood fool friend"
# expected output
["food fool friend","d","fool"]

An empty array is returned if there is no match

# spq
values regexp("bar", this)
# input
"foo"
# expected output
[]