I am trying to pass variables using a regular expression (re.search) but I can't seem to successfully read the information into match.group(1)
, (2)
etc. using the code below. Could someone take a quick look to see where I'm going wrong?
serial = 'abcdeID:11111abcdePR:22222abcde'
id = 11111
pr = 22222
match = re.search(r'ID:{0}PR:{1}'.format(id, pr), serial)
print("ID value returned = " + match.group(1))
print("PR value returned = " + match.group(2))
#output
#AttributeError: 'NoneType' object has no attribute 'group'