Re: [PATCH] proposal for regexp_count, regexp_instr, regexp_substr and regexp_replace

From: Gilles Darold <gilles(at)darold(dot)net>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: Chapman Flack <chap(at)anastigmatix(dot)net>
Subject: Re: [PATCH] proposal for regexp_count, regexp_instr, regexp_substr and regexp_replace
Date: 2021-03-20 18:48:48
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


This is a new version of the patch that now implements all the XQUERY
regexp functions as described in the standard, minus the differences of
PostgerSQL regular expression explain in [1].

The standard SQL describe functions like_regex(), occurrences_regex(),
position_regex(), substring_regex() and translate_regex() which
correspond to the commonly named functions regexp_like(),
regexp_count(), regexp_instr(), regexp_substr() and regexp_replace() as
reported by Chapman Flack in [2]. All these function are implemented in
the patch. Syntax of the functions are:

- regexp_like(string, pattern [, flags ])

- regexp_count( string, pattern [, position ] [, flags ])

- regexp_instr( string, pattern [, position ] [, occurrence ] [,
returnopt ] [, flags ] [, group ])

- regexp_substr( string, pattern [, position ] [, occurrence ] [, flags
] [, group ])

- regexp_replace(source, pattern, replacement [, position ] [,
occurrence ] [, flags ])

In addition to previous patch version I have added the regexp()_like
function and extended the existsing regex_replace() function. The patch
documents these functions and adds regression tests for all functions. I
will add it to the commitfest.

An other regexp functions regexp_positions() that returns all
occurrences that matched a POSIX regular expression is also developped
by Joel Jacobson, see [2]. This function expands the list of regexp
functions described in XQUERY.



Gilles Darold
LzLabs GmbH

Attachment Content-Type Size
v2-0001-xquery-regexp-functions.patch text/x-patch 71.4 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2021-03-20 18:52:10 Re: [HACKERS] Custom compression methods
Previous Message Mark Rofail 2021-03-20 18:42:17 Re: [HACKERS] GSoC 2017: Foreign Key Arrays