Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Detecting capture groups that *must* match for the entire regexp to match

34 views
Skip to first unread message

Chet Murthy

unread,
Feb 8, 2023, 11:22:50 AM2/8/23
to PCRE2 discussion list
Hello,

I wonder if there's any entrypoints buried someplace in PCRE, that would allow to detect when a capture group of a regexp is "mandatory", in the sense that if the regexp matches, then the capture group will match?  For example, in the following regexp:

/(a)(b)?(c)/

groups 1,3 are mandatory, and group 2 is not.

I realize that one can parse and analyze the regexp, and failing finding some code that already does this, that's my plan, but I figured I should ask first.  I've searched the documentation, but found nothing like this, hence my question.

Thanks,
--chet--

Reply all
Reply to author
Forward
0 new messages