Replace First Occurrence of a Substring in a String

Thierry Douez th.douez at gmail.com
Sun Sep 21 05:24:57 EDT 2014


2014-09-21 10:55 GMT+02:00
Peter W A Wood <peterwawood at gmail.com>:

> Many thanks Thierry.

You are welcome :)

and here is my preferate:

   put "cat and dog" into t
   if matchChunk( t, "(and)", p0, p1) then \
         put "AND" into char p0 to p1 of t

Regards,

Thierry


>>>        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