Re: Replacing characters (Matt: bug)
- Posted by Dan Moyer <DANIELMOYER at prodigy.net> Sep 18, 2002
- 520 views
Andy, Well, on the one hand it's your routine, so you should know, but on the other hand, my test results show it does replace one with two. Maybe there's something wrong with my test?? I'll send you another copy of the zip of the test I applied (previously sent twice to the forum), but here's the pertinent variables, & a copy of one line of the results (the fact that it says "Replace_in_string" instead of "replace_in_string" is just to distinguish two different routines with the same name in the test, the one with "R" is yours): <code snippet> integer tr -- test repetitions sequence r, rb -- replace, replace by text = {} new = {} times = {} r = {')'} -- replace rb = {"ZZ"} --replace by tr = 5000 -- number of test repetitions <snip code> for n = 1 to tr do new = Replace_in_string(text, r, rb) end for <code snippet ends> Original line of text from a file (Henri's original offering): so = repeat(o, length(s)) -- here is the trick Same line after output from your routine: so = repeat(o, length(sZZZZ -- here is the trick Dan Moyer ----- Original Message ----- From: "Andy Serpa" <renegade at earthling.net> To: "EUforum" <EUforum at topica.com> Sent: Tuesday, September 17, 2002 10:07 PM Subject: RE: Replacing characters (Matt: bug) > > > > > Actually, neither one will handle replacements of different lengths. > > > > The test I ran (& zipped previously) *did* show Andy's replacing one > > with > > two. That same instance of doubled parentheses mentioned above ("))") > > was > > replaced by "ZZZZ" in my test. > > > > > The replace_in_string function? It shouldn't have replaced two-for-one. > I don't even see how it is possible -- are you sure? > > That function should really be called "tranlate" or something as it is > not meant as a substring search-and-replace. > > > >