Skip to content

Add the regular expression functions that find each match - #227

Merged
tamnd merged 1 commit into
mainfrom
regexpall
Oct 9, 2026
Merged

tamnd merged 1 commit into
mainfrom
regexpall

Conversation

@tamnd

@tamnd tamnd commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Part of #3.

This change adds the regular expression functions that find each match in a string. The views of information_schema and the queries of client tools use some of them, such as regexp_replace. With this change, rupg has all the regular expression functions of PostgreSQL 19.

What changes

  • Regex::find_chars finds a match from a given character. The constraints, such as ^ and a lookbehind, still see the characters before that place, as in pg_regexec.
  • setup_matches ports setup_regexp_matches. It finds the first match or each match, and the search after an empty match starts one character later.
  • regexp_replace has its five forms. The replacement takes \1 to \9, \& and \\, as appendStringInfoRegexpSubstr does. Options that start with a digit give the error of PostgreSQL with its hint.
  • regexp_count, regexp_instr and regexp_substr have each of their forms, with the checks of start, n, endoption and subexpr.
  • regexp_matches and regexp_split_to_table are set-returning functions in FROM. regexp_split_to_array gives the same parts as an array. An empty match at the end of the string or just after a match does not split the string.

Test

  • The new session test regex_matches runs a script and compares the result with the output of PostgreSQL 19 for the same script in a new database. It covers each function and form, empty matches, a start after the first character, characters of more than one byte, LATERAL, each error and a view.
  • srvtest passed on server1: fmt, layers, style, clippy, all the workspace tests, the generated file checks and the docs.

@tamnd tamnd added this to the M2: Connect and introspect milestone Oct 9, 2026
@tamnd tamnd added kind/feature It does not do something that it must do. kind/compat A difference from PostgreSQL 19 at one of the five levels L1 to L5. area/functions Built-in functions and operators. labels Oct 9, 2026
@tamnd tamnd self-assigned this Oct 9, 2026
@tamnd
tamnd merged commit f275a64 into main Oct 9, 2026
5 checks passed
@tamnd
tamnd deleted the regexpall branch October 9, 2026 19:05
This was referenced Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/functions Built-in functions and operators. kind/compat A difference from PostgreSQL 19 at one of the five levels L1 to L5. kind/feature It does not do something that it must do.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant