# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r".*(playlist[^;]+;).*"
test_str = ("<code lang=\"javascript\">\n"
"playlist: {\n"
" id: 1 ,\n"
" seasons:[{\"season\":8,\"blocked\":false,\"episodes\":[{\"episode\":\"1\",\"id\":252323,\"hlsList\":{\"1080\":\"https://m1.rumer.club/manifest/MTc4LjE1OS4yMTUuOTY=/?video=https%3A%2F%2Fhls-t001-l001-c051-s001.vidstr.club%2F06_30_20%2F06%2F30%2F03%2FHASZJ7WG%2FPSZ4DDK2.mp4%2Ftracks%2Fv1-a%2Fmaster.m3u8\",\"480\":\"https://m1.rumer.club/manifest/MTc4LjE1OS4yMTUuOTY=/?video=https%3A%2F%2Fhls-t001-l001-c051-s001.vidstr.club%2F06_30_20%2F06%2F30%2F03%2FHASZJ7WG%2FPSZ4DDK2.mp4%2Ftracks%2Fv2-a%2Fmaster.m3u8\",\"720\":\"https://m1.rumer.club/manifest/MTc4LjE1OS4yMTUuOTY=/?video=https%3A%2F%2Fhls-t001-l001-c051-s001.vidstr.club%2F06_30_20%2F06%2F30%2F03%2FHASZJ7WG%2FPSZ4DDK2.mp4%2Ftracks%2Fv1-a%2Fmaster.m3u8\"},\"audio\":{\"names\":[\"Рус. Дублированный\",\"AlexFilm\",\"LostFilm\",\"JASKIER\",\"HDRezka Studio\",\"AMS\",\"Fox\",\"Novamedia\",\"FocusStudio\",\"НеЗупиняйПродакшн (укр)\",\"Eng.Original\"],\"order\":[3,1,0,5,6,7,2,8,9,4,10]},\"cc\":[{\"url\":\"https://hls-c1.vidstr.club/06_30_20/06/30/02/RTPE2OFQ/GGNIJSJX.vtt\",\"name\":\"Рус. форсированные\"}],\"duration\":3187,\"title\":\"Игра престолов (8 сезон) - 1 серия\"},{\"episode\":\"10\",\"id\":223739,\"dash\":\"https://m1.rumer.club/manifest/MTc4LjE1OS4yMTUuOTY=/?video=https%3A%2F%2Fhls-t001-l001-c058-s001.pixars.org%2F05_20%2F29%2F23%2FCQWEUCBD%2F570778.mpd\",\"hlsList\":{\"1080\":\"https://m1.rumer.club/manifest/MTc4LjE1OS4yMTUuOTY=/?video=https%3A%2F%2Fhls-t001-l001-c058-s001.vidstr.club%2F05_29_20%2F05%2F29%2F18%2FWAH732XV%2FIMG6I4IA.mp4%2Ftracks%2Fv1-a%2Fmaster.m3u8\",\"480\":\"https://m1.rumer.club/manifest/MTc4LjE1OS4yMTUuOTY=/?video=https%3A%2F%2Fhls-t001-l001-c058-s001.vidstr.club%2F05_29_20%2F05%2F29%2F18%2FWAH732XV%2FIMG6I4IA.mp4%2Ftracks%2Fv2-a%2Fmaster.m3u8\",\"720\":\"https://m1.rumer.club/manifest/MTc4LjE1OS4yMTUuOTY=/?video=https%3A%2F%2Fhls-t001-l001-c058-s001.vidstr.club%2F05_29_20%2F05%2F29%2F18%2FWAH732XV%2FIMG6I4IA.mp4%2Ftracks%2Fv1-a%2Fmaster.m3u8\"},\"audio\":{\"names\":[\"AlexFilm\",\"LostFilm\",\"Fox\",\"Рус. Дублированный\",\"Укр. Дубльований\",\"Eng.Original\",\"Eng. Orig. with Commentary\"],\"order\":[1,0,2,3,4,5,6]},\"cc\":[{\"url\":\"https://hls-c1.vidstr.club/05_29_20/05/29/18/F4RPKISV/HOXVWRJ5.vtt\",\"name\":\"Рус. форсированные\"}],\"duration\":3157,\"title\":\"Игра престолов (1 сезон) - 10 серия\"}]}]\n"
" },\n"
" theme: \"2\"\n"
" });\n\n\n"
"</code></spoiler>")
subst = "$1"
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0, re.MULTILINE | re.DOTALL)
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