pgpcre
pgpcre
pgpcre : Perl Compatible Regular Expression functions
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 4230 | pgpcre | pgpcre | 0.20190509 | UTIL | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d-r | No | Yes | No | Yes | yes | no |
| Relationships | |
|---|---|
| See Also | icu_ext fuzzystrmatch pg_trgm gzip bzip zstd http pg_net |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | MIXED | 0.20190509 | 18 17 16 15 14 | pgpcre | - |
| RPM | PIGSTY | 0.20190509 | 18 17 16 15 14 | pgpcre_$v | - |
| DEB | PGDG | 0.20190509 | 18 17 16 15 14 | postgresql-$v-pgpcre | - |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64 | PGDG 0.20190509 | PIGSTY 0.20190509 | PIGSTY 0.20190509 | PIGSTY 0.20190509 | PIGSTY 0.20190509 |
el8.aarch64 | PGDG 0.20190509 | PIGSTY 0.20190509 | PIGSTY 0.20190509 | PIGSTY 0.20190509 | PIGSTY 0.20190509 |
el9.x86_64 | PGDG 0.20190509 | PIGSTY 0.20190509 | PIGSTY 0.20190509 | PIGSTY 0.20190509 | PIGSTY 0.20190509 |
el9.aarch64 | PGDG 0.20190509 | PIGSTY 0.20190509 | PIGSTY 0.20190509 | PIGSTY 0.20190509 | PIGSTY 0.20190509 |
el10.x86_64 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 |
el10.aarch64 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 |
d12.x86_64 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 |
d12.aarch64 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 |
d13.x86_64 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 |
d13.aarch64 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 |
u22.x86_64 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 |
u22.aarch64 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 |
u24.x86_64 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 |
u24.aarch64 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 | PGDG 0.20190509 |
Source
pig build pkg pgpcre; # build rpmInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install pgpcre; # install via package name, for the active PG version
pig install pgpcre -v 18; # install for PG 18
pig install pgpcre -v 17; # install for PG 17
pig install pgpcre -v 16; # install for PG 16
pig install pgpcre -v 15; # install for PG 15
pig install pgpcre -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION pgpcre;Usage
pgpcre: Perl-compatible regular expressions (PCRE) for PostgreSQL
Provides a pcre data type and operators/functions for PCRE pattern matching.
Basic Matching
SELECT 'foo' ~ pcre 'fo+'; -- true
SELECT 'bar' !~ pcre 'fo+'; -- true
SELECT 'foo' =~ pcre 'fo+'; -- true (Perl-style operator)Reverse operand order:
SELECT pcre 'fo+' ~ 'foo'; -- true
SELECT pcre 'fo+' ~ ANY(ARRAY['foo', 'bar']);Case-Insensitive Matching
SELECT 'FOO' ~ pcre '(?i)fo+'; -- trueExtract Matched String
SELECT pcre_match('fo+', 'foobar'); -- 'foo'
SELECT pcre_match('fo+', 'barbar'); -- NULLExtract Captured Substrings
SELECT pcre_captured_substrings('(fo+)(b..)', 'foobar');
-- ARRAY['foo','bar']
SELECT pcre_captured_substrings('(a|(z))(bc)', 'abc');
-- ARRAY['a',NULL,'bc']Storing Regular Expressions
The pcre type can be stored in table columns. The binary form contains the compiled regex, tied to the PCRE library version. After a PCRE library upgrade, recompile stored values:
UPDATE my_table SET pcre_col = pcre_col::text::pcre;Last updated on