(?3)
isn't valid in Java. It is parsed as an "inline modifier" as mentioned in the error message, which is a way to activate a flag for the remainder of the regex (or until an opposite (?-X)
is encountered), for example (?i)
to enable case-insensitive search. There's no flag named 3
, hence the error.
It is however valid in some PCRE implementations (most notably in Perl which is the reference implementation for PCRE) and makes it possible to refer to a capturing group, enabling at the same time the possibility to define recursive patterns. This is how it is used in this regex.
Rewriting the regex to be compatible with Java would require some non-trivial work, and it would be interesting to ponder whether a regex implementation is still preferable to some other code without this feature.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…