import re
regex = re.compile(r"(\"[^<,\"]+)|([^>\n]+(?=<))|\n|.*<strong>|<\/strong\>.*|<\/?ul>")
test_str = ("\"1\",\"ANYDATA-481190-131\",\"<ul>\n"
"<li><strong>487410-131</strong> (prateado)</li>\n"
"<li><strong>502478-131</strong></li>\n"
"<li><strong>555996-131</strong> (prateado)</li>\n"
"<li><strong>AEQT6T11110</strong></li>\n"
"<li><strong>AEQT6T00210</strong></li>\n"
"</ul>\"")
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