Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

pcre2

> 编程语言
Open source

PCRE2 development is based here.

1.3K stars0 likes0 views
WebsiteGitHub

About

PCRE2 development is based here.

Overview

The PCRE2 library is a set of C functions that implement regular expression pattern matching.

It is self-contained and portable, and designed to be easy to embed into existing projects and build systems, on almost any platform or build target.

The PCRE2 library is free and open-source (BSD licence), and permitted in proprietary software.

It supports Unicode matching and a very wide range of regular expression features. It accepts input in various character encodings, and optionally includes a highly performant JIT matching engine.

PCRE2 is mature and highly-trusted: bundled in dozens or hundreds of open-source and commercial products, such as Excel, Safari, Apache, and Git, and used as the basis for regular expressions in several programming languages including PHP and R.

Website

https://pcre2project.github.io/pcre2/

Distribution   Testing                

Platforms Tested continuously on Linux, Windows, macOS, FreeBSD, OpenBSD, Solaris, z/OS;

x86, ARM, RISC-V, POWER, S390X; others known to work

Quickstart

Show script

…

File demo.c:

…
bash
git clone https://github.com/PCRE2Project/pcre2.git
```

Please use a release tag in production, not the development branch!

Because PCRE2's JIT uses code from a Git submodule, you must check this out after a fresh clone:

```
git submodule update --init
```
  1. Via download of the release tarball.

  2. Finally, PCRE2 is also bundled by various downstream package managers (such as Linux distributions, or vcpkg). These are provided by third parties, not the PCRE2 project.

The main ways of building PCRE2 are:

  1. Via CMake (Linux/Windows/macOS, and others)

    bash
    cd pcre2/
    cmake -B build .
    cmake --build build/
  2. Via Autoconf (Linux/Unix)

    bash
    cd pcre2/
    ./configure
    make

See "Platforms" below for links to more detailed build documentation.

API Overview

The PCRE2 API supports strings in 8-bit, 16-bit, and 32-bit encodings, with or without UTF encoding. There is also EBCDIC support.

The default regular expression dialect closely matches the syntax and behaviour of Perl 5, with PCRE2-specific extensions. A wide variety of granular flags can be passed to the PCRE2 API to customise this to more closely follow other dialects such as JavaScript or Python.

The default matching engine uses a depth-first tree search with backtracking, which is highly feature-rich but has worst-case exponential time (PCRE2 allows aborting the match if a time limit is exceeded, expressed as a maximum number of steps in the tree search). The second matching engine uses a JIT for greatly improved performance, compiling the regular expression to a block of equivalent native machine code.

PCRE2 has a third matching engine, using a DFA engine which is generally slower, but has worst-case polynomial matching time and is able to find the POSIX-style "leftmost-longest" match.

There are accompanying utility functions for converting glob patterns and POSIX BRE/ERE patterns to PCRE2 regular expressions; and also for performing high-level regular expression operations such as search-and-replace with a powerful replacement string syntax.

As well as the PCRE2 API, the library also offers a POSIX-compatible `` header and regexec() function. However, this does not provide the ability to pass PCRE2 flags, so we recommend users consume the PCRE2 API if possible.

See the full library and API documentation for further details.

For third-party documentation, see:

  • A curated summary of changes for each PCRE release, and some excellent tutorials on PCRE2 on the RexEgg website.
  • Jan Goyvaerts' popular Regular-Expressions.info site includes information about PCRE2 as well as tutorials and highly detailed comparisons of PCRE2 to other regular expression dialects.
  • Jeffrey Friedl's book Mastering Regular Expressions includes chapters on Perl and PCRE, and is available in print and online via O'Reilly Media.

Platforms

PCRE2 is portable C code, and is likely to work on any system with a C99 compiler.

Operating systems

Our continuous integration tests on Linux (GCC and Clang, glibc and musl), Windows (MSVC and MinGW-x64), and macOS (Clang), as well as FreeBSD, OpenBSD, Solaris (Oracle Studio cc), and z/OS (xlc and ibm-clang).

Processors

PCRE2 is tested continuously on x86 (i686 and amd64), ARM 32- and 64-bit (armv7 and aarch64), RISC-V (riscv64), POWER (ppc64le), and the big-endian S390x.

Other systems are likely to work (including mobile, embedded platforms, and commercial UNIX systems), but these are not tested continuously by the PCRE2 maintainers. Users are encouraged to run the full PCRE2 test suite when compiling for any new platform. We are aware of working ports to VMS and z/OS (PCRE2 supports EBCDIC).

PCRE2 releases support CMake for building, and for UNIX platforms include a ./configure script built by Autoconf. Build files for the Bazel build system and zig build are also included. Integrating PCRE2 with other systems can be done by including the .c files in an existing project.

Please see the files README and NON-AUTOTOOLS-BUILD for full build documentation, as well as the man pages, including man pcre2/doc/pcre2build.3.

Licence

PCRE2 is released under the BSD 3-clause licence with a PCRE2 Exception. It is open-source and also corporate-friendly.

  • See LICENCE for legal text.
  • See AUTHORS for details of the current maintainers of PCRE2 and acknowledgements of its contributors, including Philip Hazel, the original author.

Contributing & support

Join the community by reporting issues or asking questions via GitHub issues. We welcome feedback and proposals.

Contributions ranging from bug fixes to feature requests are welcome, and can be made via GitHub pull requests.

Our support lifecycle is to backport security and high-severity bug fixes for at least five years. See SUPPORT-LIFECYCLE for how to package older versions of PCRE2.

Please review our SECURITY policy for information on reporting security issues.

Release announcements will be made via the [email protected] mailing list, where you can also start discussions about PCRE2 issues and development. You can browse the list archives.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言