Re: PCRE partial matching
| From: | C. Scott Ananian | Date: | Wed, 20 Mar 2019 15:26:12 +0000 |
| Subject: | Re: PCRE partial matching | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-104830@lists.php.net to get a copy of this message | ||
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)