import regex,re
sequence = 'aaaaaaaaaaaabbbbbbbbbbbbcccccccccccc' #being searched
query = 'aaabbbbbbbbbbbbccc' #100% coverage
query_1 = 'aaaabbbbbbbbcbbbcccc' #95% coverage
query_2 = 'aaabbbbcbbbbbcbccc' #90% coverage
threshold = .95
error = len(query_1) - (len(query_1)*threshold) #for query_1 errors must be <= 1
print regex.search(query_1 + '{e<={}}'.format(error),sequence).group(0)
我试图向正则表达式搜索添加其他参数,因此它仅在按顺序搜索一定百分比的查询时才有效。
例如,如果我希望它至少有 95% 的覆盖率,它会起作用,query_1
但它不会起作用query_2