Ref:
import re def num_groups(regex): return re.compile(regex).groups some_regex_str = 'miehaha_([A-Za-z0-9_-]+)' print num_groups(some_regex_str) # output: 1
Recommended Posts