# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(?siU).*\"temp\":(.*),.*\"description\":\"(.*)\".*daily.*\"dt\":(.*),.*\"min\":(.*),.*\"max\":(.*),.*\"description\":\"(.*)\".*\"dt\":(.*),.*\"min\":(.*),.*\"max\":(.*),.*\"description\":\"(.*)\".*\"dt\":(.*),.*\"min\":(.*),.*\"max\":(.*),.*\"description\":\"(.*)\".*\"dt\":(.*),.*\"min\":(.*),.*\"max\":(.*),.*\"description\":\"(.*)\".*\"dt\":(.*),.*\"min\":(.*),.*\"max\":(.*),.*\"description\":\"(.*)\".*\"dt\":(.*),.*\"min\":(.*),.*\"max\":(.*),.*\"description\":\"(.*)\".*\"dt\":(.*),.*\"min\":(.*),.*\"max\":(.*),.*\"description\":\"(.*)\".*\"dt\":(.*),.*\"min\":(.*),.*\"max\":(.*),.*\"description\":\"(.*)\".*"
test_str = "{\"lat\":-34.08,\"lon\":150.79,\"timezone\":\"Australia/Sydney\",\"current\":{\"dt\":1588385816,\"sunrise\":1588365147,\"sunset\":1588403702,\"temp\":17.07,\"feels_like\":11.01,\"pressure\":1003,\"humidity\":46,\"dew_point\":5.37,\"uvi\":3.47,\"clouds\":0,\"wind_speed\":7.15,\"wind_deg\":6,\"wind_gust\":12.52,\"weather\":[{\"id\":800,\"main\":\"Clear\",\"description\":\"clear sky\",\"icon\":\"01d\"}]},\"daily\":[{\"dt\":1588381200,\"sunrise\":1588365147,\"sunset\":1588403702,\"temp\":{\"day\":17.07,\"min\":8.55,\"max\":17.07,\"night\":8.55,\"eve\":14.09,\"morn\":17.07},\"feels_like\":{\"day\":12.24,\"night\":4.21,\"eve\":8.47,\"morn\":12.24},\"pressure\":1003,\"humidity\":46,\"dew_point\":5.37,\"wind_speed\":5.39,\"wind_deg\":279,\"weather\":[{\"id\":800,\"main\":\"Clear\",\"description\":\"clear sky\",\"icon\":\"01d\"}],\"clouds\":0,\"uvi\":3.47},{\"dt\":1588467600,\"sunrise\":1588451594,\"sunset\":1588490045,\"temp\":{\"day\":14.88,\"min\":7.68,\"max\":17.78,\"night\":8.4,\"eve\":16.89,\"morn\":8.56},\"feels_like\":{\"day\":10.2,\"night\":5.52,\"eve\":14.86,\"morn\":4.49},\"pressure\":1018,\"humidity\":44,\"dew_point\":3.39,\"wind_speed\":4.47,\"wind_deg\":218,\"weather\":[{\"id\":800,\"main\":\"Clear\",\"description\":\"clear sky\",\"icon\":\"01d\"}],\"clouds\":0,\"uvi\":3.57},{\"dt\":1588554000,\"sunrise\":1588538040,\"sunset\":1588576388,\"temp\":{\"day\":15.31,\"min\":6.68,\"max\":17.69,\"night\":9.37,\"eve\":15.32,\"morn\":6.83},\"feels_like\":{\"day\":13.61,\"night\":6.72,\"eve\":12.09,\"morn\":4.14},\"pressure\":1026,\"humidity\":55,\"dew_point\":6.95,\"wind_speed\":1.22,\"wind_deg\":179,\"weather\":[{\"id\":800,\"main\":\"Clear\",\"description\":\"clear sky\",\"icon\":\"01d\"}],\"clouds\":1,\"uvi\":3.58},{\"dt\":1588640400,\"sunrise\":1588624487,\"sunset\":1588662733,\"temp\":{\"day\":16.72,\"min\":9,\"max\":17.88,\"night\":11.03,\"eve\":17.09,\"morn\":9},\"feels_like\":{\"day\":15.02,\"night\":9.63,\"eve\":15.93,\"morn\":6.39},\"pressure\":1030,\"humidity\":63,\"dew_point\":10.15,\"wind_speed\":2.35,\"wind_deg\":188,\"weather\":[{\"id\":500,\"main\":\"Rain\",\"description\":\"light rain\",\"icon\":\"10d\"}],\"clouds\":20,\"rain\":0.46,\"uvi\":3.68},{\"dt\":1588726800,\"sunrise\":1588710934,\"sunset\":1588749078,\"temp\":{\"day\":16.47,\"min\":9.47,\"max\":20.25,\"night\":12.26,\"eve\":19.16,\"morn\":9.82},\"feels_like\":{\"day\":14.75,\"night\":11.65,\"eve\":17.97,\"morn\":8.33},\"pressure\":1029,\"humidity\":62,\"dew_point\":9.75,\"wind_speed\":2.2,\"wind_deg\":344,\"weather\":[{\"id\":803,\"main\":\"Clouds\",\"description\":\"broken clouds\",\"icon\":\"04d\"}],\"clouds\":64,\"uvi\":3.7},{\"dt\":1588813200,\"sunrise\":1588797380,\"sunset\":1588835425,\"temp\":{\"day\":17.89,\"min\":9.93,\"max\":21.04,\"night\":14.29,\"eve\":20.37,\"morn\":10.29},\"feels_like\":{\"day\":16.46,\"night\":13.24,\"eve\":19.37,\"morn\":9.06},\"pressure\":1025,\"humidity\":51,\"dew_point\":8.18,\"wind_speed\":1.25,\"wind_deg\":327,\"weather\":[{\"id\":804,\"main\":\"Clouds\",\"description\":\"overcast clouds\",\"icon\":\"04d\"}],\"clouds\":93,\"uvi\":3.88},{\"dt\":1588899600,\"sunrise\":1588883826,\"sunset\":1588921774,\"temp\":{\"day\":18.95,\"min\":10.71,\"max\":23.82,\"night\":14.21,\"eve\":22.89,\"morn\":11.2},\"feels_like\":{\"day\":17.59,\"night\":13.29,\"eve\":21.52,\"morn\":10.21},\"pressure\":1022,\"humidity\":55,\"dew_point\":10.17,\"wind_speed\":1.89,\"wind_deg\":334,\"weather\":[{\"id\":800,\"main\":\"Clear\",\"description\":\"clear sky\",\"icon\":\"01d\"}],\"clouds\":0,\"uvi\":3.45},{\"dt\":1588986000,\"sunrise\":1588970273,\"sunset\":1589008123,\"temp\":{\"day\":19.74,\"min\":11.48,\"max\":25.25,\"night\":14.53,\"eve\":23.02,\"morn\":11.73},\"feels_like\":{\"day\":18.36,\"night\":13.58,\"eve\":21.48,\"morn\":10.92},\"pressure\":1020,\"humidity\":52,\"dew_point\":10.27,\"wind_speed\":1.88,\"wind_deg\":336,\"weather\":[{\"id\":800,\"main\":\"Clear\",\"description\":\"clear sky\",\"icon\":\"01d\"}],\"clouds\":0,\"uvi\":3.42}]}"
matches = re.finditer(regex, test_str, re.MULTILINE)
for matchNum, match in enumerate(matches, start=1):
print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))
for groupNum in range(0, len(match.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum)))
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
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