PHP's str_replace ?
dthole at gmail.com
Wed Sep 10 20:52:25 CEST 2008
On Sep 10, 12:20 pm, Christian Heimes <li... at cheimes.de> wrote:
> 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.
It's true that regular expressions are generally slower, but I
disagree that it's hard to understand. When dealing with text, I
think it's an absolute must that programmers know about regular
expressions. I think this here is an example where even str_replace
in Python wouldn't have worked well.
More information about the Python-list