import re
regex = re.compile(r"^\s*\K\w+", flags=re.MULTILINE)
test_str = ("{\n"
" questions: [\n"
" {\n"
" name: \"name\",\n"
" type: \"text\",\n"
" title: \"Please enter your name:\",\n"
" placeHolder: \"Jon Snow\",\n"
" isRequired: true\n"
" }, {\n"
" name: \"birthdate\",\n"
" type: \"text\",\n"
" inputType: \"date\",\n"
" title: \"Your birthdate:\",\n"
" isRequired: true\n"
" }, {\n"
" name: \"color\",\n"
" type: \"text\",\n"
" inputType: \"color\",\n"
" title: \"Your favorite color:\"\n"
" }, {\n"
" name: \"email\",\n"
" type: \"text\",\n"
" inputType: \"email\",\n"
" title: \"Your e-mail:\",\n"
" placeHolder: \"jon.snow@nightwatch.org\",\n"
" isRequired: true,\n"
" validators: [\n"
" {\n"
" type: \"email\"\n"
" }\n"
" ]\n"
" }\n"
" ]\n"
"}")
subst = "\"\\0\""
result = regex.sub(subst, test_str)
if result:
print(result)
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