import re
regex = re.compile(r"\"temp\":(.*?),")
test_str = "{\"vin\":810,\"vout\":283,\"cin\":46,\"cout\":133,\"temp\":34,\"charge\":75,\"relay\":0,\"pwr\":3753,\"vch\":303,\"vfl\":303,\"ich\":40,\"ifl\":1,\"v_relay_on\":260,\"v_relay_off\":250,\"mppt_percent\":75,\"snd_ena\":1,\"light_mode\":1,\"contrOn\":1,\"bat_lo\":240,\"bat_hi\":297,\"ssidPass\":\"pass\",\"ssid\":\"GardenNet\",\"iLogin\":\"login\",\"iPass\":\"pass\",\"cloudName\":\"url\",\"cloudKey\":\"api_key\",\"ApPass\":\"11111111\",\"relay_mode\":0,\"mppt_mode\":3,\"st_mode\":0,\"refr\":10,\"modd\":18,\"eday\":71,\"etot\":7,\"sec\":32,\"min\":59,\"hour\":14,\"date\":5,\"month\":1,\"year\":19}"
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