import re
regex = re.compile(r"\<span\sclass\=\"js_value\stab-weather__value_l\"\>\s*+([+-]\d++)\s*+\<span\sclass\=\"tab-weather__value_m\"\>\s*+([.,]\d++)(?:\s*+\<\/span\>){2}", flags=re.MULTILINE)
test_str = ("<span class=\"js_value tab-weather__value_l\">\n"
" +6<span class=\"tab-weather__value_m\">,2</span></span>\n"
"<span class=\"js_value tab-weather__value_l\">\n"
" -12<span class=\"tab-weather__value_m\">.45</span></span>\n"
"<span class=\"js_value tab-weather__value_l\">\n"
" +0<span class=\"tab-weather__value_m\">,1</span></span>")
subst = "$1$2"
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