regexp.q

Regular expressions in RE2 syntax: match, extract, capture groups, replace, split and escape. subject is one string or a list of them; flags go inside the pattern: (?i) (?s) (?m). Every function is fixed-arity, so there is no options argument.

Examples

.regexp.extract["order 123 of 456";"[0-9]+"]
.regexp.replace_all[("a-b";"c-d");"-";"_"]

Entity Summary

EntitiesShort Description
.regexp.duckdb_match[handle]Whether an open DuckDB handle's RE2 is the version vendored here; answers a boolean rather than signalling, since PEACHQ_DUCKDB_LIB may legitimately point at another release.
.regexp.escape[text]The pattern that matches text literally (RE2's QuoteMeta).
.regexp.extract[subject;pattern]The first matched text, "" when nothing matches.
.regexp.extract_all[subject;pattern]Every non-overlapping match.
.regexp.full_match[subject;pattern]Does the pattern match the whole subject?
.regexp.groups[subject;pattern]The capture groups of the first match, () when nothing matches.
.regexp.groups_all[subject;pattern]One group list per match, so .regexp.groups_all[...][;1] is the second group across every match.
.regexp.matches[subject;pattern]Does the pattern match anywhere in the subject?
.regexp.replace[subject;pattern;replacement]The first match replaced.
.regexp.replace_all[subject;pattern;replacement]Every match replaced.
.regexp.split[subject;pattern]The subject split on the pattern; no match answers the subject itself as one piece.

Entity Details

.regexp.duckdb_match[handle]

Whether an open DuckDB handle's RE2 is the version vendored here; answers a boolean rather than signalling, since PEACHQ_DUCKDB_LIB may legitimately point at another release.

Examples

.regexp.duckdb_match .duckdb.main[]

.regexp.escape[text]

The pattern that matches text literally (RE2's QuoteMeta).

Examples

.regexp.matches["1+1=2";.regexp.escape "1+1"]

.regexp.extract[subject;pattern]

The first matched text, "" when nothing matches.

Examples

.regexp.extract["abc123";"[0-9]+"]

.regexp.extract_all[subject;pattern]

Every non-overlapping match.

Examples

.regexp.extract_all["a1b22c333";"[0-9]+"]

.regexp.full_match[subject;pattern]

Does the pattern match the whole subject?

Examples

.regexp.full_match["abc";"a.c"]

.regexp.groups[subject;pattern]

The capture groups of the first match, () when nothing matches.

Examples

.regexp.groups["2026-09-19";"(\\d+)-(\\d+)-(\\d+)"]

.regexp.groups_all[subject;pattern]

One group list per match, so .regexp.groups_all[...][;1] is the second group across every match.

Examples

.regexp.groups_all["a=1, b=2";"(\\w)=(\\d)"]

.regexp.matches[subject;pattern]

Does the pattern match anywhere in the subject?

Examples

.regexp.matches["Hello";"(?i)^h"]

.regexp.replace[subject;pattern;replacement]

The first match replaced.

Parameters:
  • replacement - may name capture groups as \1 to \9

Examples

.regexp.replace["2026-09-19";"(\\d+)-(\\d+)-(\\d+)";"\\3/\\2/\\1"]

.regexp.replace_all[subject;pattern;replacement]

Every match replaced.

Parameters:
  • replacement - may name capture groups as \1 to \9

Examples

.regexp.replace_all["a1b2";"[0-9]";"#"]

.regexp.split[subject;pattern]

The subject split on the pattern; no match answers the subject itself as one piece.

Examples

.regexp.split["a, b;c";"[,;] *"]