Help with RegExps

mehta at mama.indstate.edu mehta at mama.indstate.edu
Mon Sep 27 23:07:34 EDT 1999


>>> import re
>>> s = 'sometext <a href=HelloWorld>hello</a>somemoretext'
>>> d = re.compile (r'(.*?<.*>)(.*)$')
>>> k = d.sub (r'\1<font color=ffggff>\2', s)
>>> k
'sometext <a href=HelloWorld>hello</a><font color=ffggff>somemoretext'
>>>


In article <7sb22v$kmi at dfw-ixnews12.ix.netcom.com>,
  aahz at netcom.com (Aahz Maruch) wrote:
> In article <37E8B7B3.F4A9143 at isogmbh.de>, Chris... <sca at isogmbh.de>
wrote:
> >
> >  I am looking for an regular expression that changes text, only if
it
> >is not anywhere between '<' and '>'.
> >For example, add syntax highlighting to HTML-file:
> >    'some text <a href=#someRef>ref</a> # this is a comment'
> >should be changed to
> >    'some text <a href=#someRef>ref</a> <font color=blue># this is a
> >comment</font>'
>
> Try using htmllib instead; already packages all the regexes for you.
> (Make sure to use 1.5.2; there are a couple of bugs in 1.5.1)
> --
>                       --- Aahz (@netcom.com)
>
> Androgynous poly kinky vanilla queer het    <*>
http://www.rahul.net/aahz/
> Hugs and backrubs -- I break Rule 6  (if you want to know, do some
research)
>


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list