import re
regex = re.compile(r"<h(?:[\d]{1})(?:.*?)>(.*?)<\/h(?:[\d]{1})>")
test_str = "<h1 class=\"text-align-center\" style=\"font-size:22px;margin-top:0px;margin-bottom:0px;color:rgb(0,0,0);font-family:IntroBold, sans-serif;line-height:1.5;letter-spacing:0px;font-weight:700;text-align:center;\">You should be confident solving wicked problems in a hybrid role between strategy, research, design and business through a discovery driven approach. </h1><p></p><h2 style=\"margin-top:0px;margin-bottom:.5em;font-family:IntroBold, sans-serif;font-size:19px;line-height:1em;text-transform:uppercase;letter-spacing:1px;font-weight:700;\"><strong>KEY RESPONSIBILITIES</strong></h2>"
subst = "<strong>$1</strong>"
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