I have the following piece of code Note: Line variable is from a line in a text file I'm reading and pattern variable is saved in a config file which I pickup and apply in the code
line ="[u'INVOICE# SMR/0038 f"', u'', u'', u'']"
pattern ='(?<=(invoice#)\s)[A-z]{3}/\d{1,5}'
regex = re.compile(r'' + pattern),re.IGNORECASE)
invNum= re.findall(pattern, str(line),re.IGNORECASE)[0]
........
I'm expecting to get invNum = SMR/0038
but instead I get invoice#
. What's the issue?
if try this pattern on https://regexr.com/ I see that the lookbehind is working. But transferring it to Python code doesn't work. See image below from https://regexr.com/