Python re Regular Expression (Regex) Positive Look Behind


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 or re.findall() instead.

import re

pattern = r'(?<=TDY)[0-9][1-9]'
stringIn = '/XYZ01/TDY01/L01'

# using re.findall
print re.findall(pattern, stringIn)

# using
search =, stringIn)
if search:
	print 'Found:',
	print 'Not found'


Found: 01

The difference between and 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!

1 Like