Why regular expression's "non-capturing" group is not working
- by Jim Horng
In my snippet below, the non-capturing group "(?:aaa)" should be ignored in matching result,
so the result should be "_bbb" only.
However, I get "aaa_bbb" in matching result; only when I specify group(2) does it show "_bbb".
import re
string1 = "aaa_bbb"
print(re.match(r"(?:aaa)(_bbb)", string1).group())
>>> aaa_bbb