# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(?:.*?:(\".*?\"))|(.*)"
test_str = "{\"maps\":{\"idOthers\":{\"label\":\"Others\",\"state\":1,\"bkmrk\":{}}},\"portals\":{\"id1472374017624\":{\"label\":\"Teslin, YT\",\"state\":1,\"bkmrk\":{\"id1471384290640\":{\"guid\":\"1c742997732a404190ad947a1e2ad1f1.12\",\"latlng\":\"60.176809,-132.790461\",\"label\":\"Teslin Heritage Centre, Yt - j\"},\"id1471384292759\":{\"guid\":\"0ff8105df28b4291bb388bb3169992b0.16\",\"latlng\":\"60.167183,-132.707912\",\"label\":\"Moose And Caribou Replica\"},\"id1471384291685\":{\"guid\":\"80e38740843f43489e5c3b9bcb4017e6.16\",\"latlng\":\"60.16109,-132.693209\",\"label\":\"Village of Teslin Gazebo\"},\"id1471384293782\":{\"guid\":\"71e8bd86f50c4fd9844f3d4091b92325.16\",\"latlng\":\"60.167443,-132.707359\",\"label\":\"Wildlife Gallery\"}}},\"id1472374213379\":{\"label\":\"Watson Lake, YT\",\"state\":1,\"bkmrk\":{\"id1472374223764\":{\"guid\":\"32b7435123914d6d8c470f1c9c3d03b2.16\",\"latlng\":\"60.066292,-128.704744\",\"label\":\"Wye Lake Gazebo\"},\"id1472374224152\":{\"guid\":\"52f7f7cbac894342a5e83a97a46c7422.16\",\"latlng\":\"60.065734,-128.705368\",\"label\":\"Wye Lake Park\"},\"id1472374224529\":{\"guid\":\"04b586b6c30c42ce84bdb7f85d9f2d16.16\",\"latlng\":\"60.065442,-128.704187\",\"label\":\"Horned & Common Dandelions\"},\"id1472374225092\":{\"guid\":\"f657a17af2dc48c6966aa32a83f2b1f9.16\",\"latlng\":\"60.062886,-128.7068\",\"label\":\"First Wye Lake Park\"},\"id1472374225511\":{\"guid\":\"33498408d348447d9cde3fdb180dc038.16\",\"latlng\":\"60.064183,-128.714208\",\"label\":\"Watson Lake Information Center\"},\"id1472374225978\":{\"guid\":\"da5df8fb86d44476b4372ba0295ae2af.12\",\"latlng\":\"60.063748,-128.715488\",\"label\":\"Watson Lake Sign Post Forest -\"},\"id1472374226806\":{\"guid\":\"33f693fa6735446a8d848300487b46f0.16\",\"latlng\":\"60.065042,-128.713877\",\"label\":\"Watson Lake Recreation Centre\"},\"id1472374227184\":{\"guid\":\"e968d06b86264aae882b41038e6c19c1.16\",\"latlng\":\"60.06444,-128.715315\",\"label\":\"Robert Campbell Highway Information\"},\"id1472374223273\":{\"guid\":\"84d9bc723f7c4d7e98a7a62ec86f7a68.16\",\"latlng\":\"60.062733,-128.704699\",\"label\":\"Watson Lake Library\"}}},\"idOthers\":{\"label\":\"Others\",\"state\":1,\"bkmrk\":{\"id1472374171311\":{\"guid\":\"445808e24dd840d5b24b407edd8f664b.16\",\"latlng\":\"60.027705,-129.080566\",\"label\":\"Native Outlook\"},\"id1472374176673\":{\"guid\":\"184a20a3b1694bf68c89354680d7b674.16\",\"latlng\":\"60.027904,-129.080963\",\"label\":\"Nugget Totem\"}}}}} "
subst = "$1"
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0, re.IGNORECASE)
if result:
print (result)
# 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