Regex and the OR operator without grouping in Python? Regex and the OR operator without grouping in Python? python python

Regex and the OR operator without grouping in Python?


A ?: inside a parenthesis in a regex makes it non-capturing. Like so: (?:AB|CDE)_\d{2,3}

See docs here: http://docs.python.org/3/library/re.htmlAbout a third of the way through it goes over the non-capturing syntax.


The non-capturing group syntax is (?:...). So do (?:AB|CDE)_\d{2,3}. This is documented along with everything else.