# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"((var|const|let)\s+)?[A-Za-z0-9_\.\[\]\"\']+\s?=\s+?{"
test_str = ("acf0.data = {\"select2L10n\":{\"matches_1\":\"Es ist ein Ergebnis verf\\u00fcgbar, dr\\u00fccke die Eingabetaste um es auszuw\\u00e4hlen.\",\"matches_n\":\"Es sind %d Ergebnisse verf\\u00fcgbar, benutze die Pfeiltasten um nach oben und unten zu navigieren.\",\"matches_0\":\"Keine \\u00dcbereinstimmungen gefunden\",\"input_too_short_1\":\"Gib bitte ein oder mehr Zeichen ein\",\"input_too_short_n\":\"Gib bitte %d oder mehr Zeichen ein\",\"input_too_long_1\":\"L\\u00f6sche bitte ein Zeichen\",\"input_too_long_n\":\"L\\u00f6sche bitte %d Zeichen\",\"selection_too_long_1\":\"Du kannst nur ein Element ausw\\u00e4hlen\",\"selection_too_long_n\":\"Du kannst nur %d Elemente ausw\\u00e4hlen\",\"load_more\":\"Mehr Ergebnisse laden…\",\"searching\":\"Suchen…\",\"load_fail\":\"Laden fehlgeschlagen\"},\"google_map_api\":\"https:\\/\\/maps.googleapis.com\\/maps\\/api\\/js?key=AIzaSyDzJU4YaeA4XDHAN1BvFOZD8A2eF5lxYr0&libraries=places&ver=3&callback&language=de_DE\",\"datePickerL10n\":{\"closeText\":\"Fertig\",\"currentText\":\"Heute\",\"nextText\":\"N\\u00e4chstes\",\"prevText\":\"Vorheriges\",\"weekHeader\":\"W\",\"monthNames\":[\"Januar\",\"Februar\",\"M\\u00e4rz\",\"April\",\"Mai\",\"Juni\",\"Juli\",\"August\",\"September\",\"Oktober\",\"November\",\"Dezember\"],\"monthNamesShort\":[\"Jan\",\"Feb\",\"Mrz\",\"Apr\",\"Mai\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Okt\",\"Nov\",\"Dez\"],\"dayNames\":[\"Sonntag\",\"Montag\",\"Dienstag\",\"Mittwoch\",\"Donnerstag\",\"Freitag\",\"Samstag\"],\"dayNamesMin\":[\"S\",\"M\",\"D\",\"M\",\"D\",\"F\",\"S\"],\"dayNamesShort\":[\"So\",\"Mo\",\"Di\",\"Mi\",\"Do\",\"Fr\",\"Sa\"]},\"dateTimePickerL10n\":{\"timeOnlyTitle\":\"Zeit ausw\\u00e4hlen\",\"timeText\":\"Zeit\",\"hourText\":\"Stunde\",\"minuteText\":\"Minute\",\"secondText\":\"Sekunde\",\"millisecText\":\"Millisekunde\",\"microsecText\":\"Mikrosekunde\",\"timezoneText\":\"Zeitzone\",\"currentText\":\"Jetzt\",\"closeText\":\"Fertig\",\"selectText\":\"Ausw\\u00e4hlen\",\"amNames\":[\"Vorm.\",\"Vorm.\"],\"pmNames\":[\"Nachm.\",\"Nachm.\"]},\"colorPickerL10n\":{\"hex_string\":\"Hex String\",\"rgba_string\":\"RGBA String\"},\"mimeTypeIcon\":\"https:\\/\\/wptest.photoclub-reutlingen.de\\/wp-includes\\/images\\/media\\/default.png\",\"mimeTypes\":{\"jpg|jpeg|jpe\":\"image\\/jpeg\",\"gif\":\"image\\/gif\",\"png\":\"image\\/png\",\"bmp\":\"image\\/bmp\",\"tiff|tif\":\"image\\/tiff\",\"webp\":\"image\\/webp\",\"ico\":\"image\\/x-icon\",\"heic\":\"image\\/heic\",\"asf|asx\":\"video\\/x-ms-asf\",\"wmv\":\"video\\/x-ms-wmv\",\"wmx\":\"video\\/x-ms-wmx\",\"wm\":\"video\\/x-ms-wm\",\"avi\":\"video\\/avi\",\"divx\":\"video\\/divx\",\"flv\":\"video\\/x-flv\",\"mov|qt\":\"video\\/quicktime\",\"mpeg|mpg|mpe\":\"video\\/mpeg\",\"mp4|m4v\":\"video\\/mp4\",\"ogv\":\"video\\/ogg\",\"webm\":\"video\\/webm\",\"mkv\":\"video\\/x-matroska\",\"3gp|3gpp\":\"video\\/3gpp\",\"3g2|3gp2\":\"video\\/3gpp2\",\"txt|asc|c|cc|h|srt\":\"text\\/plain\",\"csv\":\"text\\/csv\",\"tsv\":\"text\\/tab-separated-values\",\"ics\":\"text\\/calendar\",\"rtx\":\"text\\/richtext\",\"css\":\"text\\/css\",\"vtt\":\"text\\/vtt\",\"dfxp\":\"application\\/ttaf+xml\",\"mp3|m4a|m4b\":\"audio\\/mpeg\",\"aac\":\"audio\\/aac\",\"ra|ram\":\"audio\\/x-realaudio\",\"wav\":\"audio\\/wav\",\"ogg|oga\":\"audio\\/ogg\",\"flac\":\"audio\\/flac\",\"mid|midi\":\"audio\\/midi\",\"wma\":\"audio\\/x-ms-wma\",\"wax\":\"audio\\/x-ms-wax\",\"mka\":\"audio\\/x-matroska\",\"rtf\":\"application\\/rtf\",\"pdf\":\"application\\/pdf\",\"class\":\"application\\/java\",\"tar\":\"application\\/x-tar\",\"zip\":\"application\\/zip\",\"gz|gzip\":\"application\\/x-gzip\",\"rar\":\"application\\/rar\",\"7z\":\"application\\/x-7z-compressed\",\"psd\":\"application\\/octet-stream\",\"xcf\":\"application\\/octet-stream\",\"doc\":\"application\\/msword\",\"pot|pps|ppt\":\"application\\/vnd.ms-powerpoint\",\"wri\":\"application\\/vnd.ms-write\",\"xla|xls|xlt|xlw\":\"application\\/vnd.ms-excel\",\"mdb\":\"application\\/vnd.ms-access\",\"mpp\":\"application\\/vnd.ms-project\",\"docx\":\"application\\/vnd.openxmlformats-officedocument.wordprocessingml.document\",\"docm\":\"application\\/vnd.ms-word.document.macroEnabled.12\",\"dotx\":\"application\\/vnd.openxmlformats-officedocument.wordprocessingml.template\",\"dotm\":\"application\\/vnd.ms-word.template.macroEnabled.12\",\"xlsx\":\"application\\/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\"xlsm\":\"application\\/vnd.ms-excel.sheet.macroEnabled.12\",\"xlsb\":\"application\\/vnd.ms-excel.sheet.binary.macroEnabled.12\",\"xltx\":\"application\\/vnd.openxmlformats-officedocument.spreadsheetml.template\",\"xltm\":\"application\\/vnd.ms-excel.template.macroEnabled.12\",\"xlam\":\"application\\/vnd.ms-excel.addin.macroEnabled.12\",\"pptx\":\"application\\/vnd.openxmlformats-officedocument.presentationml.presentation\",\"pptm\":\"application\\/vnd.ms-powerpoint.presentation.macroEnabled.12\",\"ppsx\":\"application\\/vnd.openxmlformats-officedocument.presentationml.slideshow\",\"ppsm\":\"application\\/vnd.ms-powerpoint.slideshow.macroEnabled.12\",\"potx\":\"application\\/vnd.openxmlformats-officedocument.presentationml.template\",\"potm\":\"application\\/vnd.ms-powerpoint.template.macroEnabled.12\",\"ppam\":\"application\\/vnd.ms-powerpoint.addin.macroEnabled.12\",\"sldx\":\"application\\/vnd.openxmlformats-officedocument.presentationml.slide\",\"sldm\":\"application\\/vnd.ms-powerpoint.slide.macroEnabled.12\",\"onetoc|onetoc2|onetmp|onepkg\":\"application\\/onenote\",\"oxps\":\"application\\/oxps\",\"xps\":\"application\\/vnd.ms-xpsdocument\",\"odt\":\"application\\/vnd.oasis.opendocument.text\",\"odp\":\"application\\/vnd.oasis.opendocument.presentation\",\"ods\":\"application\\/vnd.oasis.opendocument.spreadsheet\",\"odg\":\"application\\/vnd.oasis.opendocument.graphics\",\"odc\":\"application\\/vnd.oasis.opendocument.chart\",\"odb\":\"application\\/vnd.oasis.opendocument.database\",\"odf\":\"application\\/vnd.oasis.opendocument.formula\",\"wp|wpd\":\"application\\/wordperfect\",\"key\":\"application\\/vnd.apple.keynote\",\"numbers\":\"application\\/vnd.apple.numbers\",\"pages\":\"application\\/vnd.apple.pages\"},\"toolbars\":{\"full\":{\"1\":\"formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,wp_more,spellchecker,fullscreen,wp_adv\",\"2\":\"strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help\",\"3\":\"\",\"4\":\"\"},\"basic\":{\"1\":\"bold,italic,underline,blockquote,strikethrough,bullist,numlist,alignleft,aligncenter,alignright,undo,redo,link,fullscreen\"}},\"admin_url\":\"https:\\/\\/wptest.photoclub-reutlingen.de\\/wp-admin\\/\",\"ajaxurl\":\"https:\\/\\/wptest.photoclub-reutlingen.de\\/wp-admin\\/admin-ajax.php\",\"nonce\":\"6f1ca57d8e\",\"acf_version\":\"5.10.1\",\"wp_version\":\"5.8.1\",\"browser\":\"chrome\",\"locale\":\"de_DE\",\"rtl\":false,\"screen\":null,\"post_id\":null,\"validation\":null,\"editor\":\"classic\"};\n")
matches = re.search(regex, test_str)
if matches:
print ("Match was found at {start}-{end}: {match}".format(start = matches.start(), end = matches.end(), match = matches.group()))
for groupNum in range(0, len(matches.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = matches.start(groupNum), end = matches.end(groupNum), group = matches.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