import re
regex = re.compile(r"(\"[^\s\"]+\":\s*\")\d+(?:\.\w+(?:-\w+)*)+\",", flags=re.MULTILINE)
test_str = ("\"@material-ui/core\": \"4.11.4\",\n"
"\"@material-ui/icons\": \"4.11.2\",\n"
"\"@material-ui/lab\": \"4.0.0-alpha.58\",\n"
"\"@material-ui/styles\": \"4.11.4\",")
subst = "$10.0.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