Function StrWhile(tcStr, tcRepl, tcReplWith) >Do While Atc(tcRepl, tcStr)>0 And tcRepl#tcReplWith > tcStr2=Strtran(tcStr, tcRepl, tcReplWith) > If tcStr2==tcStr > Exit > Else > tcStr=tcStr2 > Endif >Enddo >Return tcStr >>The reason I have this if/else block is that it sometimes doesn't replace the string. I've set the watch on the atc() expression, and it remains unchanged, somewhere about 200K or more.
TEXT TO lcSample noshow Hi Dragan, how are you?DRagan how are you? Dragandrop interface. endtext ? StrWhile(m.lcSample,"\bDragan\b","Cetin") ? StrWhile(m.lcSample,"dragan","Cetin") FUNCTION StrWhile(tcStr, tcRepl, tcReplWith) oRX = Createobject("VBScript.RegExp") With oRX .Pattern = m.tcRepl .IgnoreCase = .T. .Global = .T. ENDWITH RETURN oRX.Replace(m.tcStr, m.tcReplWith)Cetin