正则表达式不匹配所有括号子字符串

Regex not matching all the paranthesis substrings

'''txt = "但无论如何,(不是所有)基督徒相信 在同一神学中,例如后期圣徒所相信的。(他们 会叫喊“异端”和其他“歪曲”教义的指控 圣经,而他们自己相信无数的解释,因为 在他们的要理问答和各种自助圣经学习手册中找到)

对于我来说,我个人认为前世的情景是 上面的解释,最符合圣经教义,一些死海 滚动书籍、伪文字、其他来源,最后但不是 至少,关于这个主题的现代启示。”'''

我想匹配(不是全部)和(他们...手册)。但无论我尝试什么,我都在获取第二个子字符串或第一个子字符串。 我想获取两个子字符串。即括号内的所有子串 有人可以帮我解决这个问题吗??

正则表达式中的括号用于表示组。如果你想按字面匹配它们,你必须 'escape' 它们:

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

输出:

['(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)']