` Printed Icetips Article

Icetips Article



Par2: String replacement function
2007-09-28 -- Peter Hermansen
 
STRPOS!

I've written a class with a few text manipulating methods. Here's the one 
you need. You can turn it into a function if you don't want to do the class 
thing.

EDFuncClass.ReplaceAll  Procedure(STRING pOldStr, STRING pNewStr, STRING 
pText)
! Replaces all occurencies of pOldStr in pText with pNewStr
X   LONG,Auto

 Code
 loop
    X = STRPOS(pText,pOldStr,True)
    if X
       pText = pText[1 : X-1] & Clip(pNewStr) & pText[X + LEN(Clip(pOldStr)) 
: LEN(Clip(pText))]
    else
       BREAK
    end
 end
 RETURN(pText)



Printed April 27, 2024, 1:59 am
This article has been viewed/printed 35112 times.