Regex not matching all the paranthesis substrings [duplicate]

Parenthesis in regular expressions are used to indicate groups. If you want to match them literally, you must ‘escape’ them:

import re
found = re.findall(r'\(.*?\)', text)
print(found)

Outputs:

['(not all)', '(They will cry "heresy" and other accusations of "perverting" the doctrines of the Bible, while they themselves believe in a myriad of interpretations, as found in their catechisms and various do-it-yourself Bible-study manuals)']

Leave a Comment