现在有一个需求,比如给定如下数据: 0-0-0 0:0:0 #### the 68th annual golden globe awards #### the king s speech earns 7 nominations #### <LOCATION>LOS ANGELES</LOCATION> <ORGANIZATION>Dec Xinhua Kings Speech</ORGANIZATION> historical drama British k…
贪婪模式也就是我们使用 .* 匹配任意字符时会尽可能长地向后匹配,如果我们想阻止这种贪婪模式,需要加个问号,尽可能少地匹配,如下例子: In []: import re In []: html = '<h1> hello world </h1>' In []: re.findall(r'<.*>', html) # 贪婪模式默认匹配到所有内容 Out[]: ['<h1> hello world </h1>'] In []: re.findall(…