fixed.
import re text1=***** text2=***** text3=***** textsub = [text1,text2,text3] Invoicenumbercapture = r"(\d+)" for text in textsub: print((re.search(Invoicenumbercapture, text)).group())