Data 360 SQL and Tableau Hyper API
Window Functions
unnest
external
generate_series (Numerical)
generate_series (Time-based)
regexp_matches
result_scan
DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
regexp_matchesApplies to: ✅ Data 360 SQL ✅ Tableau Hyper API
Returns the captured groups of each match of a regular expression pattern against a string, as a set of rows.
1regexp_matches(<string>, <pattern> [, flags])<string>: The string to search.<pattern>: The regular expression pattern to match. Must contain at least one capturing group.flags: A string of option flags that modify matching behavior. Use g to return every match instead of only the first.| Flag | Description |
|---|---|
g | Global matching — return every match, not just the first |
Returns a set of rows, each containing a text[] array of the captured groups for one match.
g flag, returns at most one row (the first match).g flag, returns one row per match.<string> or <pattern> is NULL.regexp_matches, which falls back to the whole match when there are no groups.WITH ORDINALITY to number the returned rows. See Set Returning Functions.text[] array across a set of rows. For a single scalar result instead, use REGEXP_SUBSTR, which returns the text of the first captured group of the first match directly.Extract two captured groups from the first match.
1SELECT * FROM regexp_matches('foobarbequebaz', '(bar)(beque)') AS m(groups)Returns one row: ["bar", "beque"].
Use the g flag to return every match, one row per match.
1SELECT * FROM regexp_matches('foobarbequebazilbarfbonk', '(b[^b]+)(b[^b]+)', 'g') AS m(groups)Returns:
| groups |
|---|
| [“bar”, “beque”] |
| [“bazil”, “barf”] |
1SELECT * FROM regexp_matches('foobarbequebazilbarfbonk', '(b[^b]+)(b[^b]+)', 'g') WITH ORDINALITY AS m(groups, ordinality)Returns:
| groups | ordinality |
|---|---|
| [“bar”, “beque”] | 1 |
| [“bazil”, “barf”] | 2 |
1SELECT * FROM regexp_matches('S', 'S') AS m(groups)Raises an error because the pattern doesn’t contain a capturing group.