Re: Best way to handle multiple string replacements?

Subject: Re: Best way to handle multiple string replacements?
From: Jeni Tennison <Jeni.Tennison@xxxxxxxxxxxxxxxx>
Date: Tue, 06 Jun 2000 15:32:48 +0100

At 01:40 PM 6/6/00 +0100, Sebastian Rahtz wrote:
>I am full of admiration for Jeni's ingenuity, but I wonder whether a
>simpler approach might not be to build  a lookup table of character
>positions and their expansions (using XSL keys), and then cycle over
>the text letter by letter seeing if there is a replacement?

I'm not sure that I understand the method your proposing.  Do you mean to


defining the characters to be escaped, and then index into them using
substring()?  That would work just as well for those characters, but how
would you do the string replacements?  If you have the time, could you put
together the (pseudo)code to elucidate your method?

>If you work by cycling through the replacements, surely
>will fight? the $ in the second fragment might end up escaped

Not so - the replacements are done in order, and the same order each time
(so it is predictable).  As in Warren's original example, all the
single-character escaping is done first (by the replace_characters
template), and all the string replacements are done second (by the
replace_strings template).



Dr Jeni Tennison
Epistemics Ltd, Strelley Hall, Nottingham, NG8 6PE
Telephone 0115 9061301 ? Fax 0115 9061304 ? Email

 XSL-List info and archive:

Current Thread