我们不能在正则表达式中给出一个字符串吗?例如,re.compile('((.*)?=<Bangalore>)')
,在下面的代码中我提到了<Bangalore>
,但它没有显示。你知道吗
我想在班加罗尔之前提取文本。你知道吗
import re
regex = re.compile('((.*)?=<>)')
line = ("Kathick Kumar, Bangalore who was a great person and lived from 29th
March 1980 - 21 Dec 2014")
result = regex.search(line)
print(result)
期望输出:Kathick Kumar,班加罗尔
使用
(.*)(?:Bangalore)
模式像这样的?你知道吗
相关问题 更多 >
编程相关推荐