php8.5
Home/ Manual/ reference / pcre/ Regular Expressions (Perl-Compatible)

Regular Expressions (Perl-Compatible)

This extension integrates regular expression pattern matching support into PHP. It is based on the free and open-source PCRE2 library. This library implements regular expression pattern matching using syntax and semantics compatible with Perl, with a few documented differences. See Pattern Syntax and Pattern Modifiers for a detailed explanation.

Intro

This extension integrates regular expression pattern matching support into PHP. It is based on the free and open-source PCRE2 library. This library implements regular expression pattern matching using syntax and semantics compatible with Perl, with a few documented differences. See Pattern Syntax and Pattern Modifiers for a detailed explanation.

To improve performance, the extension caches compiled regular expressions. Each thread has its own dedicated cache, capable of holding up to 4096 expressions.

Note

When the cache is full, a batch of the oldest entries that are not currently in use is discarded to make room for new ones. The cache size is not configurable.

Warning

PCRE2 imposes size and other limits that may be relevant in some cases.

Setup Constants Examples Pattern Reference

Source: reference/pcre/book.xml · from the official PHP manual (php/doc-en)