Perl s/ To Python?

John Abel jabel at plus.net
Fri Jun 10 10:19:23 EDT 2005


JZ wrote:

>Dnia Fri, 10 Jun 2005 14:57:21 +0100, John Abel napisał(a):
>
>  
>
>>$testVar =~ s#/mail/.*$##g
>>
>>The only way I can think of doing it, is:
>>
>>mailPos = testVar.find( "mail" )
>>remainder =  testVar[ :mailPos ]
>>
>>Any ideas would be appreciated.  I'm iterating over a lot of entries, 
>>and running these lines for each entry.
>>    
>>
>
>import re
>testVar = re.compile(r'/mail/.*$').sub('', testVar) 
>
>--
>JZ
>  
>
That's brill.  Never even thought if using re.  Thank you!

J



More information about the Python-list mailing list