I'm trying to learn Atom's syntax highlighting/grammar rules, which heavily use JS regular expressions, and came across an unfamiliar pattern in the python grammar file.
The pattern starts with a (?x)
which is an unfamiliar regex to me. I looked it up in an online regex tester, which seems to say that it's invalid. My initial thought was it represents an optional left paren, but I believe the paren should be escaped here.
Does this only have meaning in the Atom's coffeescript grammar, or am I overlooking a regex meaning?
(This pattern also appear in the textmate language file that I believe Atom's came from).
If that regular expression gets processed in Python, it'll be compiled with the 'verbose' flag.
From the Python re
docs:
(?aiLmsux)
(One or more letters from the set 'a', 'i', 'L', 'm', 's', 'u', 'x'.) The group matches the empty string; the letters set the corresponding flags: re.A (ASCII-only matching), re.I (ignore case), re.L (locale dependent), re.M (multi-line), re.S (dot matches all), and re.X (verbose), for the entire regular expression. (The flags are described in Module Contents.) This is useful if you wish to include the flags as part of the regular expression, instead of passing a flag argument to the re.compile() function.