pgpcre
Perl Compatible Regular Expression functions
Repository
petere/pgpcre
https://github.com/petere/pgpcre
Source
pgpcre-0.20190509.tar.gz
pgpcre-0.20190509.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pgpcre | 0.20190509 | UTIL | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4230 | pgpcre | No | Yes | No | Yes | No | Yes | - |
| Related | icu_ext fuzzystrmatch pg_trgm gzip bzip zstd http pg_net |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | MIXED | 0.20190509 | 1817161514 | pgpcre | - |
| RPM | PIGSTY | 0.20190509 | 1817161514 | pgpcre_$v | - |
| DEB | PGDG | 0.20190509 | 1817161514 | postgresql-$v-pgpcre | - |
Build
You can build the RPM packages for pgpcre using pig build:
pig build pkg pgpcre # build RPM packages
Install
You can install pgpcre directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pgpcre; # Install for current active PG version
pig ext install -y pgpcre -v 18 # PG 18
pig ext install -y pgpcre -v 17 # PG 17
pig ext install -y pgpcre -v 16 # PG 16
pig ext install -y pgpcre -v 15 # PG 15
pig ext install -y pgpcre -v 14 # PG 14
dnf install -y pgpcre_18 # PG 18
dnf install -y pgpcre_17 # PG 17
dnf install -y pgpcre_16 # PG 16
dnf install -y pgpcre_15 # PG 15
dnf install -y pgpcre_14 # PG 14
apt install -y postgresql-18-pgpcre # PG 18
apt install -y postgresql-17-pgpcre # PG 17
apt install -y postgresql-16-pgpcre # PG 16
apt install -y postgresql-15-pgpcre # PG 15
apt install -y postgresql-14-pgpcre # PG 14
Create Extension:
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+'; -- true
Extract Matched String
SELECT pcre_match('fo+', 'foobar'); -- 'foo'
SELECT pcre_match('fo+', 'barbar'); -- NULL
Extract 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;
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.