Skip to content

Provide a parser termination character #861

@NWilson

Description

@NWilson

I'm a little surprised we don't seem to have this, and no-one has asked for it before (apparently). The PCRE2 rules for processing backslashes, including \Q...\E, are rather complicated, making it hard to do a scan of a regex to find where it ends.

For example, suppose an application has a text format or syntax that encloses a regex in /.../im slashes with trailing options. The application calls PCRE2 to parse when it encounters the opening slash. But how does the application know where it ends?

Currently, I believe that the application has to duplicate a fair amount of backslash escaping logic, and work out where the first (unescaped) slash is, and pass in the contents of the regex to PCRE2.

It would be preferable, to me, to offer a method on the compile context to set a terminator character. When PCRE2 encounters this, it stops, as if it had reached the end of the pattern, and the compile context can also return the terminator position (or NULL if end-of-string was encountered without seeing a terminator).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions