Find out number of capture groups in Python regular expressions April 20, 2023 by Tarik def num_groups(regex): return re.compile(regex).groups