import re
regex = re.compile(r"([:\[,])(?![+-]?\d+\.?\d*)(?!false|true)(?!\".*?\")([^\{\[\r\n]*?)([,\]\}])")
test_str = ("\"bla\":12.0,\n"
"\"bla\":+12.0,\n"
"\"bla\":-12.0,\n"
"\"bla\":+12,\n"
"\"bla\":false,\n"
"\"bla\":true,\n"
"\"bla\":+12.0.0,\n"
"\"bla\":\"string\",\n"
"\"bla\":path,\n"
"\"bla\":pathWith0.2,\n"
"\"bla\":,\n"
"\"bla\":{\"inner\":false,\"bli\":\"s\",\"blu\":path},\n"
"\"bla\":[path1,path2,path3},\n")
subst = "$1\"$2\"$3"
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