PCRE partial matching

php.internals

Nikita Popov

7 years ago
Hi internals, PCRE has some very nice partial matching functionality described at https://www.pcre.org/current/doc/html/pcre2partial.html. This is useful for streaming processing, as it allows you to distinguish between "there's definitely no match here" and "this could match starting from position N, but we need more data to find out". Here is a PR to expose this functionality from PHP: https://github.com/php/php-src/pull/3969 The PR has a basic description of the API. What do you think? Nikita

C. Scott Ananian

7 years ago
Looks nice to me. In connection with the PREG_LENGTH_CAPTURE option floated in a previous post, this would easily let the wikimedia/remex-html package parse HTML in a streaming fashion; it would fill up a buffer array and then do an incremental parse, stopping as soon as a (hard) partial match was found, then move the prefix returned to the start of the buffer, wait for the buffer to fill more, then restart. --scott On Wed, Mar 20, 2019 at 5:32 AM Nikita Popov <nikita.ppv@gmail.com> wrote:
> Hi internals, > > PCRE has some very nice partial matching functionality described at > https://www.pcre.org/current/doc/html/pcre2partial.html. This is useful > for > streaming processing, as it allows you to distinguish between "there's > definitely no match here" and "this could match starting from position N, > but we need more data to find out". > > Here is a PR to expose this functionality from PHP: > https://github.com/php/php-src/pull/3969 The PR has a basic description of > the API. > > What do you think? > > Nikita >
-- (http://cscott.net)

Nikita Popov

7 years ago
On Wed, Mar 20, 2019 at 10:31 AM Nikita Popov <nikita.ppv@gmail.com> wrote:
> Hi internals, > > PCRE has some very nice partial matching functionality described at > https://www.pcre.org/current/doc/html/pcre2partial.html. This is useful > for streaming processing, as it allows you to distinguish between "there's > definitely no match here" and "this could match starting from position N, > but we need more data to find out". > > Here is a PR to expose this functionality from PHP: > https://github.com/php/php-src/pull/3969 The PR has a basic description > of the API. > > What do you think? > > Nikita >
Any more comments on this one? Nikita