question about speed of sequential string replacement vs regex or

John Bokma john at
Wed Sep 28 22:14:51 CEST 2011

Willem <willem at> writes:

> Eli the Bearded wrote:
> ) In comp.lang.perl.misc, Willem  <willem at> wrote:
> )> In Perl, it would be applicable.  You see, in Perl, you can call a function
> )> in the replacement of the regex substitution, which can then look up the
> )> html entity and return the wanted unicode literal.
> )
> ) A function? I'd use a hash.
> A function can return a sensible value for unknown substitutions.

You can do that also in the RHS of the substitution and still keep it
readable if you use something like



However, a function can be easier on the eye:

s{...}{ some_good_name( ... ) }ge;

John Bokma                                                               j3b

Blog:        Perl Consultancy:
Perl for books:

More information about the Python-list mailing list