import re
regex = re.compile(r"MaximumBatchQuantity[^:]+:(?<MaximumBatchQuantity>[^,]+)", flags=re.MULTILINE)
test_str = "{\"bdy\":{\"msg\":\"HttpRequest\",\"addInfo\":[{\"key\":\"Url\",\"value\":\"https://isp0064x.st.ad.XXXXX.com/XXXXXOmniFulfillmentServerApp/api/Assignment/Auto/\"},{\"key\":\"Content\",\"value\":\"{\\\"Filters\\\":[],\\\"MaximumBatchQuantity\\\":20,\\\"AllowedSLAMilliSeconds\\\":4500,\\\"AssociateFirstName\\\":\\\"Aliona\\\",\\\"AssociateId\\\":\\\"2795969\\\",\\\"AssociateLastName\\\":\\\"Cieniawa\\\",\\\"Header\\\":{\\\"ApiVersion\\\":null,\\\"AppVersion\\\":\\\"18.3.0.15617\\\",\\\"JsonWebToken\\\":null,\\\"MessageId\\\":\\\"de959d4f-6a7d-4c0c-98d3-1143064b4300\\\"},\\\"IsOffline\\\":false,\\\"SLARequestKey\\\":\\\"AutoBatch\\\",\\\"StoreNumber\\\":\\\"0064\\\"}\"},{\"key\":\"CorrelationId\",\"value\":\"\"},{\"key\":\"MessageId\",\"value\":\"3a04038d-64e2-493c-b489-90a922de1980\"}]},\"hdr\":{\"level\":\"Verbose\",\"timestamp\":\"2018-06-04T21:03:19.6347626Z\",\"fxsrc\":\"LogRequestInfo\",\"lineNum\":710,\"userId\":\"2795969\",\"loc\":\"Store\",\"locId\":\"0064\",\"ip\":\"10.224.255.15\",\"hostName\":\"K-W10ME-7463352\",\"macaddress\":\"00-16-XX-16-A6-FA\",\"eventid\":0,\"appVersion\":\"18.3.0.15617\",\"appName\":\"OmniFulfillment\",\"deviceModel\":\"XX500\",\"osVersion\":\"10.0.14393.2007\",\"firmwareVersion\":\"1049.7.18039.0\",\"networkSignalStrength\":\"4\",\"isConnected\":\"True\"},\"ver\":\"0.1\"}"
matches = regex.finditer(test_str)
for match_num, match in enumerate(matches, start=1):
print(f"Match {match_num} 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