Alain Pastor wrote: > OOPS there was a bug in FN REPLACE5$: the following line: P.nil`` = oldLen - ( found + oldSubStr[0] ) should have been: P.nil`` = oldLen - ( myStr[0] + oldSubStr[0] ) Here is another entry that tries to do the search in line rather than calling the INSTR function, so far it is the fastest that I could come up with, if there is no bug in it that is: LOCAL FN REPLACE8$( myStr AS STR255, oldSubStr AS STR255, newSubStr AS STR255 ) DIM P AS POINTER DIM found AS LONG DIM oldLen AS LONG DIM i AS LONG IF oldSubStr[0] = _nil THEN EXIT FN found = 0 P = @myStr oldLen = P + P.nil`` - oldSubStr[0] LONG IF oldLen > 0 "start over" DO P++ UNTIL P.nil`` = oldSubStr[1] OR P = oldLen FOR i = 2 TO oldSubStr[0] P++ IF P.nil`` != oldSubStr[i] THEN EXIT FOR NEXT LONG IF i <= oldSubStr[0] AND P < oldLen GOTO "start over" XELSE found = P - i - @myStr + 2 END IF LONG IF found P = @myStr oldLen = P.nil`` P.nil`` = found - 1 P += P.nil`` + oldSubStr[0] P.nil`` = oldLen - ( myStr[0] + oldSubStr[0] ) myStr += newSubStr + PSTR$( P ) END IF END IF END FN = myStr I pity our poor Japanese friends who have to take care of that two bytes thingy as Osamu pointed out. Relying upon the FB statement is more secure for that kind of thing. -- Cheers Alain ----------------------------------------------------- FB^3 in Europe: http://euro.futurebasic.com/ FB II Pouch: http://www.pixmix.com/FB/outils.html -----------------------------------------------------