# PCRE partial matching

- Thread: https://externals.io/message/104817
- Original archive: https://news-web.php.net/php.internals/104817
- Started by Nikita Popov on 2019-03-20T09:31:53+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #104817 — Nikita Popov — 2019-03-20T09:31:53+00:00

URL: https://externals.io/message/104817#104817

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

---

## #104830 — C. Scott Ananian — 2019-03-20T15:26:12+00:00

URL: https://externals.io/message/104817#104830

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



> 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)

---

## #105651 — Nikita Popov — 2019-05-09T10:08:16+00:00

URL: https://externals.io/message/104817#105651

> 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
