-
Notifications
You must be signed in to change notification settings - Fork 241
Description
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).