6 python regex python-3.x
有没有一种简单的方法可以将精确的字符串转换为re.compile对象?例如,我想混合精确的字符串和正则表达式。
re.compile
Lev*_*sky 10
您可能可以使用re.escape转义字符串中的所有内容,然后使用转义的字符串作为模式。
re.escape
def transform(s): return re.compile(re.escape(s))
归档时间:
12 年,5 月 前
查看次数:
4291 次
最近记录: