我正在尝试使用python的re.sub函数来替换一些文本.
>>> import re
>>> text = "<hi type=\"italic\"> the></hi>"
>>> pat_error = re.compile(">(\s*\w*)*>")
>>> pat_error.search(text)
<_sre.SRE_Match object at 0xb7a3fea0>
>>> re.sub(pat_error, ">\1", text)
'<hi type="italic">\x01</hi>'
Run Code Online (Sandbox Code Playgroud)
之后文本的值应该是
"<hi type="italic"> the</hi>"
Run Code Online (Sandbox Code Playgroud)