PHP's str_replace ?

Christian Heimes lists at cheimes.de
Wed Sep 10 13:20:31 EDT 2008


Anjanesh Lekshminarayanan wrote:
>> import re
>> new_str = re.sub('[aeiou]', '-', str)
> Wow - this is neat. Thanks

But probably slower and definitely harder to understand. For simple 
problems the str methods are usually faster than a regular expression.

Christian




More information about the Python-list mailing list