本文介绍了如何找到最佳的模糊字符串匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Python的新的正则表达式模块支持模糊字符串匹配.大声赞美(现在).
Python's new regex module supports fuzzy string matching. Sing praises aloud (now).
根据文档:
BESTMATCH
标志使模糊匹配搜索最佳匹配 而不是下一场比赛
The BESTMATCH
flag makes fuzzy matching search for the best match instead of the next match
与
,但是实际上没有设置BESTMATCH
标志.怎么样了?
but there's nothing on actually setting the BESTMATCH
flag. How's it done?
推荐答案
="a href =" https://pypi.python.org/pypi/regex"rel =" noreferrer>文档 c1>标志功能是部分的(但正在改进). Poke-n-hope显示使用(?b)
设置了BESTMATCH
.
Documentation on the BESTMATCH
flag functionality is partial (but improving). Poke-n-hope shows that BESTMATCH
is set using (?b)
.
>>> import regex
>>> regex.search(r"(?e)(?:hello){e<=4}", "What did you say, oh - hello")[0]
'hat d'
>>> regex.search(r"(?b)(?:hello){e<=4}", "What did you say, oh - hello")[0]
'hello'
这篇关于如何找到最佳的模糊字符串匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!