[Tutor] Newbie - regex question

Sam M sm9191 at gmail.com
Mon Aug 30 22:52:18 CEST 2010


Hi Guys,

I'd like remove contents between tags <email> that matches pattern "WORD1"  
as follows:

Change
"stuff <email>WORD1-EMAILID at DOMAIN.COM</email> more stuff  
<email>WORD1-EMAILID at DOMAIN.COM</email> still more stuff  
<email>WORD2-EMAILID at DOMAIN.COM</email> stuff after WORD2  
<email>WORD1-EMAILID at DOMAIN.COM</email>"

To
"stuff  more stuff  still more stuff  
<email>WORD2-EMAILID at DOMAIN.COM</email> stuff after WORD2 "

The following did not work
newl = re.sub (r'<email>WORD1-.*</email>',"",line)

Thanks in advance!


More information about the Tutor mailing list