carlos wrote:This is a more shorter and faster codification:
Reformatting and using shorter variable names is generally not considered fair game to "shorten" the code

As for faster, yours probably is so since it pre-computes the powers of 2 (instead of 1<<%%A). However, I'd be surprised if this made much of a measurable difference in practice.
If you browse the old thread linked in my previous post, there are some variations on the same theme. In particular, have a look at jeb's
http://www.dostips.com/forum/viewtopic.php?p=6267#p6267.
carlos wrote:Anyways, I ask for the method of safe string replace.
I tried to explain my method the best I could in the first post. Beyond that, I can only suggest you insert some echo's in the code to see what's going on step by step.
That said, unless you do it for pure fun, I don't recommend my code for actual work. The brute force method, for example Dave's code, is easier to follow and also provably faster, as noted in the subsequent posts.
Liviu
P.S.
Sponge Belly wrote:I have learnt the hard way not to bother Liviu until he's had his morning coffee

Hard? That was hardly hard, my friend
