re2
re2
re2 : ClickHouse-compatible regex functions using RE2
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 4235 | re2
|
re2
|
0.1.1 |
UTIL
|
PostgreSQL
|
C++
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-dtr
|
No
|
Yes
|
No
|
Yes
|
yes
|
yes
|
release 0.1.1; SQL v0.1
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY
|
0.1.1 |
18
17
16
15
14
|
re2 |
- |
| RPM | PIGSTY
|
0.1.1 |
18
17
16
15
14
|
re2_$v |
- |
| DEB | PIGSTY
|
0.1.1 |
18
17
16
15
14
|
postgresql-$v-re2 |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
MISS
|
MISS
|
el8.aarch64
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
MISS
|
MISS
|
el9.x86_64
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
MISS
|
MISS
|
el9.aarch64
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
MISS
|
MISS
|
el10.x86_64
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
MISS
|
MISS
|
el10.aarch64
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
MISS
|
MISS
|
d12.x86_64
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
MISS
|
MISS
|
d12.aarch64
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
MISS
|
MISS
|
d13.x86_64
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
MISS
|
MISS
|
d13.aarch64
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
MISS
|
MISS
|
u22.x86_64
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
MISS
|
MISS
|
u22.aarch64
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
MISS
|
MISS
|
u24.x86_64
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
MISS
|
MISS
|
u24.aarch64
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
MISS
|
MISS
|
u26.x86_64
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
MISS
|
MISS
|
u26.aarch64
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
PIGSTY 0.1.1
|
MISS
|
MISS
|
Source
pig build pkg re2; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install re2; # install via package name, for the active PG version
pig install re2 -v 18; # install for PG 18
pig install re2 -v 17; # install for PG 17
pig install re2 -v 16; # install for PG 16
pig install re2 -v 15; # install for PG 15
pig install re2 -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION re2;Usage
Sources: official README, official reference doc, v0.1.1 release
re2 provides ClickHouse-compatible regular expression functions backed by Google’s RE2 engine. It exposes both text and bytea overloads, so binary data with \\0 bytes can be searched too.
CREATE EXTENSION re2;
SELECT re2match('hello world', 'h.*o');
SELECT re2extract('Order #123', '(\\d+)');
SELECT re2countmatches('a1 b2 c3', '\\d');Core Functions
re2match(haystack, pattern) -> booleanre2extract(haystack, pattern) -> text|byteare2extractall(haystack, pattern) -> text[]|bytea[]re2regexpextract(haystack, pattern, index default 1) -> text|byteare2extractgroups(haystack, pattern) -> text[]|bytea[]re2replaceregexpone(haystack, pattern, replacement) -> text|byteare2replaceregexpall(haystack, pattern, replacement) -> text|byteare2countmatches(...)andre2countmatchescaseinsensitive(...)
Multi-Pattern Matching
The re2multimatch* family accepts either multiple pattern arguments or a VARIADIC array:
SELECT re2multimatchany('error: timeout', 'timeout', 'denied');
SELECT re2multimatchanyindex('error: timeout', VARIADIC ARRAY['timeout', 'denied']);
SELECT re2multimatchallindices('error: timeout', 'error', 'timeout', 'panic');Matching Semantics
- To match ClickHouse behavior,
.matches line breaks by default. - Prefix the pattern with
(?-s)if you want.not to cross line breaks. - Replacement strings support
\\0through\\9backreferences.
Caveats
- Upstream requires the system
re2library at build/install time. - The
v0.1.1release is binary-only: it adds PostgreSQL 13+ support and documentsVARIADICuse for multi-pattern functions, but existingv0.1SQL installations do not needALTER EXTENSION UPDATE.
Last updated on