re2
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
re2 | 0.4.1 | UTIL | PostgreSQL | C++ |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4245 | re2 | No | Yes | No | Yes | Yes | Yes | - |
Stable PGXN and PIGSTY package release 0.4.1 for PostgreSQL 16 through 18.
Version
| OS / PG | PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|---|
| el8.x86_64 | N/A | PIGSTY 0.4.1 el8.x86_64.pg18 : re2_18 re2_18-0.4.1-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.4.1 el8.x86_64.pg17 : re2_17 re2_17-0.4.1-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.4.1 el8.x86_64.pg16 : re2_16 re2_16-0.4.1-1PGSTY.el8.x86_64.rpm
| N/A |
| el8.aarch64 | N/A | PIGSTY 0.4.1 el8.aarch64.pg18 : re2_18 re2_18-0.4.1-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.4.1 el8.aarch64.pg17 : re2_17 re2_17-0.4.1-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.4.1 el8.aarch64.pg16 : re2_16 re2_16-0.4.1-1PGSTY.el8.aarch64.rpm
| N/A |
| el9.x86_64 | PIGSTY 0.4.1 el9.x86_64.pg19 : re2_19 re2_19-0.4.1-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.4.1 el9.x86_64.pg18 : re2_18 re2_18-0.4.1-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.4.1 el9.x86_64.pg17 : re2_17 re2_17-0.4.1-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.4.1 el9.x86_64.pg16 : re2_16 re2_16-0.4.1-1PGSTY.el9.x86_64.rpm
| N/A |
| el9.aarch64 | PIGSTY 0.4.1 el9.aarch64.pg19 : re2_19 re2_19-0.4.1-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.4.1 el9.aarch64.pg18 : re2_18 re2_18-0.4.1-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.4.1 el9.aarch64.pg17 : re2_17 re2_17-0.4.1-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.4.1 el9.aarch64.pg16 : re2_16 re2_16-0.4.1-1PGSTY.el9.aarch64.rpm
| N/A |
| el10.x86_64 | PIGSTY 0.4.1 el10.x86_64.pg19 : re2_19 re2_19-0.4.1-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.4.1 el10.x86_64.pg18 : re2_18 re2_18-0.4.1-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.4.1 el10.x86_64.pg17 : re2_17 re2_17-0.4.1-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.4.1 el10.x86_64.pg16 : re2_16 re2_16-0.4.1-1PGSTY.el10.x86_64.rpm
| N/A |
| el10.aarch64 | PIGSTY 0.4.1 el10.aarch64.pg19 : re2_19 re2_19-0.4.1-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.4.1 el10.aarch64.pg18 : re2_18 re2_18-0.4.1-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.4.1 el10.aarch64.pg17 : re2_17 re2_17-0.4.1-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.4.1 el10.aarch64.pg16 : re2_16 re2_16-0.4.1-1PGSTY.el10.aarch64.rpm
| N/A |
| d12.x86_64 | PIGSTY 0.4.1 d12.x86_64.pg19 : postgresql-19-re2 postgresql-19-re2_0.4.1-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.4.1 d12.x86_64.pg18 : postgresql-18-re2 postgresql-18-re2_0.4.1-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.4.1 d12.x86_64.pg17 : postgresql-17-re2 postgresql-17-re2_0.4.1-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.4.1 d12.x86_64.pg16 : postgresql-16-re2 postgresql-16-re2_0.4.1-1PGSTY~bookworm_amd64.deb
| N/A |
| d12.aarch64 | PIGSTY 0.4.1 d12.aarch64.pg19 : postgresql-19-re2 postgresql-19-re2_0.4.1-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.4.1 d12.aarch64.pg18 : postgresql-18-re2 postgresql-18-re2_0.4.1-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.4.1 d12.aarch64.pg17 : postgresql-17-re2 postgresql-17-re2_0.4.1-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.4.1 d12.aarch64.pg16 : postgresql-16-re2 postgresql-16-re2_0.4.1-1PGSTY~bookworm_arm64.deb
| N/A |
| d13.x86_64 | PIGSTY 0.4.1 d13.x86_64.pg19 : postgresql-19-re2 postgresql-19-re2_0.4.1-1PGSTY~trixie_amd64.deb
| PIGSTY 0.4.1 d13.x86_64.pg18 : postgresql-18-re2 postgresql-18-re2_0.4.1-1PGSTY~trixie_amd64.deb
| PIGSTY 0.4.1 d13.x86_64.pg17 : postgresql-17-re2 postgresql-17-re2_0.4.1-1PGSTY~trixie_amd64.deb
| PIGSTY 0.4.1 d13.x86_64.pg16 : postgresql-16-re2 postgresql-16-re2_0.4.1-1PGSTY~trixie_amd64.deb
| N/A |
| d13.aarch64 | PIGSTY 0.4.1 d13.aarch64.pg19 : postgresql-19-re2 postgresql-19-re2_0.4.1-1PGSTY~trixie_arm64.deb
| PIGSTY 0.4.1 d13.aarch64.pg18 : postgresql-18-re2 postgresql-18-re2_0.4.1-1PGSTY~trixie_arm64.deb
| PIGSTY 0.4.1 d13.aarch64.pg17 : postgresql-17-re2 postgresql-17-re2_0.4.1-1PGSTY~trixie_arm64.deb
| PIGSTY 0.4.1 d13.aarch64.pg16 : postgresql-16-re2 postgresql-16-re2_0.4.1-1PGSTY~trixie_arm64.deb
| N/A |
| u22.x86_64 | PIGSTY 0.4.1 u22.x86_64.pg19 : postgresql-19-re2 postgresql-19-re2_0.4.1-1PGSTY~jammy_amd64.deb
| PIGSTY 0.4.1 u22.x86_64.pg18 : postgresql-18-re2 postgresql-18-re2_0.4.1-1PGSTY~jammy_amd64.deb
| PIGSTY 0.4.1 u22.x86_64.pg17 : postgresql-17-re2 postgresql-17-re2_0.4.1-1PGSTY~jammy_amd64.deb
| PIGSTY 0.4.1 u22.x86_64.pg16 : postgresql-16-re2 postgresql-16-re2_0.4.1-1PGSTY~jammy_amd64.deb
| N/A |
| u22.aarch64 | PIGSTY 0.4.1 u22.aarch64.pg19 : postgresql-19-re2 postgresql-19-re2_0.4.1-1PGSTY~jammy_arm64.deb
| PIGSTY 0.4.1 u22.aarch64.pg18 : postgresql-18-re2 postgresql-18-re2_0.4.1-1PGSTY~jammy_arm64.deb
| PIGSTY 0.4.1 u22.aarch64.pg17 : postgresql-17-re2 postgresql-17-re2_0.4.1-1PGSTY~jammy_arm64.deb
| PIGSTY 0.4.1 u22.aarch64.pg16 : postgresql-16-re2 postgresql-16-re2_0.4.1-1PGSTY~jammy_arm64.deb
| N/A |
| u24.x86_64 | PIGSTY 0.4.1 u24.x86_64.pg19 : postgresql-19-re2 postgresql-19-re2_0.4.1-1PGSTY~noble_amd64.deb
| PIGSTY 0.4.1 u24.x86_64.pg18 : postgresql-18-re2 postgresql-18-re2_0.4.1-1PGSTY~noble_amd64.deb
| PIGSTY 0.4.1 u24.x86_64.pg17 : postgresql-17-re2 postgresql-17-re2_0.4.1-1PGSTY~noble_amd64.deb
| PIGSTY 0.4.1 u24.x86_64.pg16 : postgresql-16-re2 postgresql-16-re2_0.4.1-1PGSTY~noble_amd64.deb
| N/A |
| u24.aarch64 | PIGSTY 0.4.1 u24.aarch64.pg19 : postgresql-19-re2 postgresql-19-re2_0.4.1-1PGSTY~noble_arm64.deb
| PIGSTY 0.4.1 u24.aarch64.pg18 : postgresql-18-re2 postgresql-18-re2_0.4.1-1PGSTY~noble_arm64.deb
| PIGSTY 0.4.1 u24.aarch64.pg17 : postgresql-17-re2 postgresql-17-re2_0.4.1-1PGSTY~noble_arm64.deb
| PIGSTY 0.4.1 u24.aarch64.pg16 : postgresql-16-re2 postgresql-16-re2_0.4.1-1PGSTY~noble_arm64.deb
| N/A |
| u26.x86_64 | PIGSTY 0.4.1 u26.x86_64.pg19 : postgresql-19-re2 postgresql-19-re2_0.4.1-1PGSTY~resolute_amd64.deb
| PIGSTY 0.4.1 u26.x86_64.pg18 : postgresql-18-re2 postgresql-18-re2_0.4.1-1PGSTY~resolute_amd64.deb
| PIGSTY 0.4.1 u26.x86_64.pg17 : postgresql-17-re2 postgresql-17-re2_0.4.1-1PGSTY~resolute_amd64.deb
| PIGSTY 0.4.1 u26.x86_64.pg16 : postgresql-16-re2 postgresql-16-re2_0.4.1-1PGSTY~resolute_amd64.deb
| N/A |
| u26.aarch64 | PIGSTY 0.4.1 u26.aarch64.pg19 : postgresql-19-re2 postgresql-19-re2_0.4.1-1PGSTY~resolute_arm64.deb
| PIGSTY 0.4.1 u26.aarch64.pg18 : postgresql-18-re2 postgresql-18-re2_0.4.1-1PGSTY~resolute_arm64.deb
| PIGSTY 0.4.1 u26.aarch64.pg17 : postgresql-17-re2 postgresql-17-re2_0.4.1-1PGSTY~resolute_arm64.deb
| PIGSTY 0.4.1 u26.aarch64.pg16 : postgresql-16-re2 postgresql-16-re2_0.4.1-1PGSTY~resolute_arm64.deb
| N/A |
Build
You can build the RPM / DEB packages for re2 using pig build:
Install
You can install re2 directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Create Extension:
Usage
Sources:
re2 provides ClickHouse-compatible regular-expression functions backed by Google’s RE2 engine. It exposes both text and bytea overloads, so binary data containing \\0 bytes can be searched too. Version 0.4.1 also adds index-assisted matching and reports the linked RE2 version.
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[]re2extractallgroupsvertical(haystack, pattern) -> text[]|bytea[]re2extractallgroupshorizontal(haystack, pattern) -> text[]|bytea[]re2regexpquotemeta(haystack) -> text|byteare2splitbyregexp(pattern, haystack, max_substrings default 0) -> 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:
Index Support
Version 0.4.0 adds two complementary index paths:
The extension also provides selectivity estimation for RE2 predicates. Check EXPLAIN with representative data before choosing between btree, GIN, and a sequential scan.
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.4.xbinaries use SQL extension version0.4; after replacing an older binary, runALTER EXTENSION re2 UPDATE TO '0.4'when an upgrade is pending. v0.4.1fixes a cache-related use-after-free and improves stable-pattern and multi-match performance; use it instead ofv0.4.0.re2splitbyregexpusespattern, haystack[, max_substrings]. Builds older than0.3.0used the reverse order.- RE2 deliberately excludes features such as backreferences in patterns and look-around assertions; its bounded-time behavior differs from PostgreSQL’s native regular-expression engine.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)