What does (?xn) and (?x) mean in the following?
st-clair-clarke opened this issue · 2 comments
lib.preexponent = XRegExp.build('(?xn)\
lib.exponent = XRegExp.build('(?x)\....
I saw them at https://blog.stevenlevithan.com/archives/grammatical-patterns-xregexp-build
Thanks
They are mode modifiers, or an alternative way to provide regex flags as part of the pattern itself. A mode modifier uses the syntax (?imnsuxA), where imnsuxA is any combination of XRegExp flags except g, y, or d (excluded since these latter flags change how various functions apply a regex rather than changing the meaning of the regex pattern itself). XRegExp allows the use of a single mode modifier (?...) at the very beginning of a pattern only. See https://xregexp.com/syntax/#modeModifier for more details.
(?xn) enables two flags: x and n, while (?x) enables just the x flag.
See https://xregexp.com/flags/ for details about these flags.
Great. Thank you.