6 Jan
2002
6 Jan
'02
6:53 p.m.
Peter Bengtsson writes:
When searching I would like to display the result where the searchterm is highlighted in someway. Like it is on google.com When you search for say "peter" the word "Peter" is highlighted with "<b>Peter</b>". So is also "<b>pEtEr</b>"
Does anybody have a little script to do the following transformation??:
searchterm="Peter"
original_string ="PEters name is peter"
result_string:
"<b>PEter</b>a name is <b>peter</b>" You look for case insensitive regular expression matching and the "sub" method.
Details in the Python documentation, module "re". Dieter