I have the following regular expression, and i need some advice about it. I need advice how can i make to highlight the text without changing the word form (uppercase to stay uppercase). I have a list of word that i like to highlight, so i got the following:
def tagText(self,listSearch,docText):
docText=docText.decode('utf-8')
for value in listSearch:
replace = re.compile(ur""+value+"", flags=re.IGNORECASE | re.UNICODE)
docText = replace.sub(u"""<b style="color:red">"""+value+"""</b>""", docText, re.IGNORECASE | re.UNICODE)
return docText