Behaviour of "Replace"
Screwed up my example (though it still illustrates the point). Lest
someone object that you shouldn't replace a space with a space in
any case, this slightly more meaningful example would also result in
an infinite loop (or rather, an overflow when the string hit 32768
characters):
Replace("Two Pints", " ", "more ") 'one space each
In article
,
"J.E. McGimpsey" wrote:
Replace() isn't recursive - it will replace each pair of spaces with
a single space as it "travels" the string left to right. Once it's
replaced the two spaces in positions 4&5, it continues with position
6. Any other way lies madness... Imagine
Replace("Two Pints", " ", " ") 'one space each
if the method started at the character it replaced with, it would
get stuck in an infinite loop.
|