[Zope] help with regular expressionism

Dieter Maurer dieter@handshake.de
Sun, 6 Jan 2002 19:53:08 +0100


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