如何检查 substirng 是否在具有特定编辑距离容差的字符串内。例如:
str = 'Python is a multi-paradigm, dynamically typed, multipurpose programming language, designed to be quick (to learn, to use, and to understand), and to enforce a clean and uniform syntax.'
substr1 = 'ython'
substr2 = 'thon'
substr3 = 'cython'
edit_distance_tolerance = 1
substr_in_str(str, substr1, edit_distance_tolerance)
>> True
substr_in_str(str, substr2, edit_distance_tolerance)
>> False
substr_in_str(str, substr3, edit_distance_tolerance)
>> True
我尝试了什么:我尝试将字符串分解为单词并删除特殊字符,然后一一进行比较,但性能(在速度和准确性方面)不是很好。
阿波罗的战车
阿晨1998
相关分类