PN_PREFIX top-level property
167s
PN_PREFIX ::= PN_CHARS_BASE ((PN_CHARS | '.')* PN_CHARS)?
Note:
- '?' zero or one time
- Using starGreedy() to avoid greedy matching all. E.g, (PN_CHARS | '.')* will consume the following PN_CHARS if not careful.
- In normal regex, a $ will be enough, with petitparser, need to use starGreedy/plusGreedy to make it work.
Implementation
final PN_PREFIX = PN_CHARS_BASE &
((PN_CHARS | string('.')).starGreedy(PN_CHARS) & PN_CHARS).repeat(0, 1);