question about speed of sequential string replacement vs regex or

Eli the Bearded * at eli.users.panix.com
Wed Sep 28 21:08:21 CEST 2011


In comp.lang.perl.misc, Willem  <willem at toad.stack.nl> 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.

> I think you can do that in some other languages as well.

Hash / array type substitutions indexed by $1 (or language equivilent)
are probably easy to implement in many languages.

Elijah
------
for really fast, write code to generate a C lexer to do it



More information about the Python-list mailing list