I’m struggling with regex (re) expression in ignition. The expression works in a regex tester, but does not work in ignition. The weird thing is that only the negative lookbehind is not working. I have other regular expression matches and they are working as normal.
Here is a snapshot of my expression functioning in a regex test environment. It successfully matches the two digits after ‘TDY’.
However, when I run this same expression and string in ignition I get no matches:
re.match() looks at the begnning of the string for the match. Try using re.search() or re.findall() instead.
pattern = r'(?<=TDY)[0-9][1-9]'
stringIn = '/XYZ01/TDY01/L01'
# using re.findall
print re.findall(pattern, stringIn)
# using re.search
search = re.search(pattern, stringIn)
print 'Found:', search.group()
print 'Not found'
The difference between
re.match has bitten me many times.
Ah thank you @JordanCClark. That solved my problem. I guess I just assumed that a match would work since I was getting the result I was looking with the online tester while having the match function selected.
Thank you for the quick help!