我有两种类型的文件。
一个包含如下行:
"55.28 LongUrl0.20s: Preplan Async"
另一个包含作为打击的行:
>55.28 LongUrl0.20s: Preplan Async</a></span><br></td>
在这两种情况下,我都希望内容以行开头LongUrl
和结尾</a>
或行尾结尾。
>>> b="55.28 LongUrl0.20s: Preplan Async"
>>> a=">55.28 LongUrl0.20s: Preplan Async</a></span><br></td>"
>>> re.findall(r'LongUrl\d*.\d*s:[^<]+',a)
['LongUrl0.20s: Preplan Async']
>>> re.findall(r'LongUrl\d*.\d*.*$',b)
['LongUrl0.20s: Preplan Async']
你能提供一个可以同时涵盖两者的 RE 吗?