import re
regex = re.compile(r"\$(.*):(.*)\;")
test_str = ("$font-heading : var(--font-heading);\n"
"$font-standard : var(--font-standard);\n"
"$body-font-size : var(--body-font-size);\n"
"$size-h1 : var(--size-h1);\n"
"$size-h2 : var(--size-h2);\n"
"$size-h3 : var(--size-h3);\n"
"$size-h4 : var(--size-h4);\n"
"$size-h5 : var(--size-h5);\n"
"$size-h6 : var(--size-h6);\n"
"$top-font-size: var(--top-font-size);\n"
"$product-font-size: var(--product-font-size);\n"
"$product-price-size: var(--product-price-size);\n"
"$product-detail-size: var(--product-detail-size);\n"
"$product-detail-title-size: var(--product-detail-title-size);\n"
"$footer-size: var(--footer-size);\n"
"/* $font-icon: 20px;\n"
"$font-small-icon: 21px;\n"
"$font-small: 14px;\n"
"$font-medium: 17px;\n"
"$font-bold: 300;\n"
"*/")
subst = "$1"
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