I am trying to capture brackets of text that have at least one digit in them (think citations). This is my regex now, and it works fine: https://regex101.com/r/oOHPvO/5
So I wanted it to capture
(Author 2000) and
(2000) but not
I am trying to use python to capture all these brackets, but in python it also captures the text in the brackets even if they don’t have digits.
import re with open('text.txt') as f: f = f.read() s = "\((?=.*\d).*?\)" citations = re.findall(s, f) citations = list(set(citations)) for c in citations: print (c)
Any ideas what I am doing wrong?