我有一个搜索表达式并突出显示匹配单词的代码。你知道吗
我需要找到匹配无论其大小写我需要搜索忽略大小写敏感。你知道吗
代码:
RepX='<u><b style="color:#FF0000">'+x+'</b></u>'
for counter , myLine in enumerate(filename):
#added
self.textEdit_PDFpreview.clear()
thematch=re.sub(x,RepX,TextString)
thematchFilt=re.findall(x,TextString,re.M|re.IGNORECASE)
搜索词示例:charles
现有单词是Charles
除非我写下Charles,否则系统将找不到搜索到的单词。你知道吗
^{} 将参数作为
re.findall(pattern, string, flags=0)
。你知道吗^{} 确保不区分大小写的匹配。你知道吗
问题出在
thematch=re.sub(x,RepX,TextString)
它还需要参数标志。 所以它变成thematch=re.sub(x,RepX,TextString,flags= re.M|re.I)
相关问题 更多 >
编程相关推荐