PCRE2 License and Legal Information
mainLICENCE.md file in the repository.repository·main·Indexed 23 days ago
https://github.com/pcre2project/pcre2A highly portable, self-contained C library for Perl-Compatible Regular Expression pattern matching. PCRE2 supports Unicode, multiple character encodings (8-bit, 16-bit, and 32-bit), and provides three matching engines: a feature-rich Backtracking engine, a high-performance JIT (Just-In-Time) engine, and a DFA engine for worst-case polynomial matching time.
LICENCE.md file in the repository.PCRE2 provides three distinct matching engines depending on your requirements:
PCRE2 uses four internal tables to identify and manipulate characters with code points less than 256. You can manage these in three ways:
pcre2_maketables() to create a new set of tables in the current locale at runtime. These tables are then passed to PCRE2 via pcre2_set_character_tables().--enable-rebuild-chartables during ./configure, the pcre2_dftables program will build a new pcre2_chartables.c using the system's default C locale (via functions like isalnum(), isalpha(), etc.).pcre2_dftables with the -b flag to generate tables in binary format instead of C source code. These binary tables are hardware-endianness independent and can be bundled with your application and passed to pcre2_compile() just like dynamically created tables.To manually run pcre2_dftables with a specific locale using the -L option:
./pcre2_dftables -L pcre2_chartables.c.special output_filePartial matching occurs when the end of the subject is reached before a complete match is found, but the pattern has already inspected characters or contains lookbehinds.
PCRE2_PARTIAL_SOFT: The matcher will continue to test other alternatives in the pattern. It only returns PCRE2_ERROR_PARTIAL if no complete match is possible.PCRE2_PARTIAL_HARD: The matcher returns PCRE2_ERROR_PARTIAL immediately upon encountering a partial match, even if an alternative complete match might exist later. This overrides SOFT mode.To verify your installation, you can compile and run a simple C demo. This example assumes you have built PCRE2 using CMake and have the build directory available.
demo.c file with the provided source code.lpcre2-8 and including the build directory for headers.Example Command:
gcc -g -I./pcre2/build -L./pcre2/build demo.c -o demo -lpcre2-8
./demo 'c.t' 'dogs and cats'gcc -g -I./pcre2/build -L./pcre2/build demo.c -o demo -lpcre2-8
./demo 'c.t' 'dogs and cats'pcre2-dev@googlegroups.com mailing list. You can also browse the list archives to view past discussions.To ensure PCRE2 uses the character tables of your system's default locale instead of the default ASCII tables, use the --enable-rebuild-chartables flag with ./configure.
If you want to provide your own custom tables, the recommended method is to move src/pcre2_chartables.c.dist out of the way and replace it with your customized version before building, to prevent the build process from automatically regenerating it.
You can obtain PCRE2 via Git clone, downloading a release tarball, or using package managers like vcpkg.
Important: If you use git clone, you must initialize the Git submodules to use the JIT matching engine.
cd pcre2/
cmake -B build .
cmake --build build/cd pcre2/
./configure
makegit clone https://github.com/PCRE2Project/pcre2.git
git submodule update --initpcre2_dftables utility with the -b flag. These tables are independent of hardware endianness and can be loaded into memory and passed to pcre2_compile().pcre2pattern documentation. PCRE2 supports Perl-compatible regular expressions with various extensions for Unicode, backtracking control, and advanced character classes.Partial matching is a PCRE2-specific feature (not Perl-compatible) used when a match is interrupted by the end of the subject string. Instead of returning PCRE2_ERROR_NOMATCH, PCRE2 can return PCRE2_ERROR_PARTIAL, indicating that adding more characters to the subject might result in a complete match.
This is useful for: