help with regular expressionism
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>"
Cheers, Peter
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
participants (2)
-
Dieter Maurer -
Peter Bengtsson