Replace First Occurrence of a Substring in a String

Thierry Douez th.douez at gmail.com
Sun Sep 21 04:40:21 EDT 2014


Peter,


>         put "Cat and Dog" into tString
>         repeat with tPos = 1 to the length of tString
>                 if char tPos of tString = "a" then
>                         put "*" into char tPos of tString
>                         exit repeat
>                 end if
>         end repeat
>

How about this one?


   get offset( "a", tString)
   if IT > 0 then put "*" into char IT of tString


Thierry


------------------------------------------------
Thierry Douez - http://sunny-tdz.com
Maker of sunnYperl - sunnYmidi - sunnYmage - sunnYpdf




More information about the use-livecode mailing list