Implement regexp_match(), a simplified alternative to regexp_matches().
Tom Lane <tgl@sss.pgh.pa.us>
Implement regexp_match(), a simplified alternative to regexp_matches(). regexp_match() is like regexp_matches(), but it disallows the 'g' flag and in consequence does not need to return a set. Instead, it returns a simple text array value, or NULL if there's no match. Previously people usually got that behavior with a sub-select, but this way is considerably more efficient. Documentation adjusted so that regexp_match() is presented first and then regexp_matches() is introduced as a more complicated version. This is a bit historically revisionist but seems pedagogically better. Still TODO: extend contrib/citext to support this function. Emre Hasegeli, reviewed by David Johnston Discussion: <CAE2gYzy42sna2ME_e3y1KLQ-4UBrB-eVF0SWn8QG39sQSeVhEw@mail.gmail.com>
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/func.sgml | modified | +109 −46 |
| src/backend/catalog/information_schema.sql | modified | +1 −1 |
| src/backend/utils/adt/regexp.c | modified | +96 −41 |
| src/include/catalog/catversion.h | modified | +1 −1 |
| src/include/catalog/pg_proc.h | modified | +6 −2 |
| src/include/utils/builtins.h | modified | +2 −0 |
| src/test/regress/expected/regex.out | modified | +28 −0 |
| src/test/regress/expected/strings.out | modified | +2 −2 |
| src/test/regress/sql/regex.sql | modified | +7 −0 |