This is from the PHP manual regarding PCRE conditional subpatterns:
The two possible forms of conditional subpattern are:
(?(condition)yes-pattern)
(?(condition)yes-pattern|no-pattern)
That’s OK as long as the condition is a digit or an assertion. But I don’t quite understand the following
If the condition is the string (R), it is satisfied if a recursive
call to the pattern or subpattern has been made. At “top level”, the
condition is false. (…) If the condition is not a sequence of digits
or (R), it must be an assertion.
I would be grateful if someone could explain on an example what (R) is in conditional subpattern and how to use it. Thanks in advance.
As an additional and clearer answer…
2 days ago I was writing a pattern to match an IPv4 address and I found myself using the recursion in condition so I thought I should share (because it makes more sense than imaginative examples).