Regular expression question

Jonah jonah13579 at hotmail.com
Sat Nov 23 21:57:11 EST 2002


What would be the python equivalent of the following perl script?  I
use the idiom often for quick templating tasks.  It finds every
occurrence of %%WHATEVER%% in $source and replaces it with the results
of a subroutine call to sub whatever (lowercased) and is passed
$variable.

$source=~ s/%%(.*?)%%/lc($1)->($variable)/eg ;

Thanks in advance.



More information about the Python-list mailing list