import re
regex = re.compile(r"InvoiceItemID\":\"(\d{6})")
test_str = "{\"ClientRef\":\"\",\"Date\":\"2015-09-29 10:02:51 AM\",\"InvoiceID\":\"451393\",\"InvoiceItemID\":\"495340\",\"Location\":\"ARN:193602013349538<br\\/>16 LEIGHLAND DR , CITY OF MARKHAM, ON, L3R 7R4\",\"ReportID\":\"268172,\",\"Type\":\"ICI Commercial \\/ Industrial Report\"},{\"ClientRef\":\"\",\"Date\":\"2015-09-28 8:39:41 PM\",\"InvoiceID\":\"451035\",\"InvoiceItemID\":\"494939\",\"Location\":\"ARN:190801210003100<br\\/>2250 SHEPPARD AVE W, CITY OF TORONTO, ON, M9M 1L7\",\"ReportID\":\"267810,\",\"Type\":\"Basic Report\"},{\"ClientRef\":\"\",\"Date\":\"2015-09-28 8:39:20 PM\",\"InvoiceID\":\"451034\",\"InvoiceItemID\":\"494938\",\"Location\":\"ARN:190801210003100<br\\/>2250 SHEPPARD AVE W, CITY OF TORONTO, ON, M9M 1L7\",\"ReportID\":\"267809,\",\"Type\":\"ICI Commercial \\/ Industrial Report\"},{\"ClientRef\":\"\",\"Date\":\"2015-09-28 2:59:03 PM\",\"InvoiceID\":\"450515\",\"InvoiceItemID\":\"494348\",\"Location\":\"ARN:240201011110900<br\\/>26-34 PLAINS RD E, BURLINGTON CITY, ON, L7T 2B9\",\"ReportID\":\"267272,\",\"Type\":\"ICI Commercial \\/ Industrial Report\"}"
match = regex.search(test_str)
if match:
print(f"Match was found at {match.start()}-{match.end()}: {match.group()}")
for group_num, group in enumerate(match.groups(), start=1):
print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html