Replace command
Peter Brigham MD
pmbrig at gmail.com
Sat Apr 10 16:34:08 EDT 2010
Right, "replace" is the thing to use for a global replace task, but if
you are doing a more sophisticated search/replace -- checking context
of various matches and narrowing the search further -- the multiple
offsets function is quite useful. Also, I need on occasion to find the
*last* occurrence of a string in a container, and "item -1 of
offsets(tString,tContainer)" is great for this.
-- Peter
Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig
On Apr 10, 2010, at 2:51 PM, Mark Schonewille wrote:
> Peter,
>
> As David pointed out, you can do that easily with the replace
> command. I thought I'll mention this to avoid confusion.
>
> --
> Best regards,
>
> Mark Schonewille
>
> Economy-x-Talk Consulting and Software Engineering
> Homepage: http://economy-x-talk.com
> Twitter: http://twitter.com/xtalkprogrammer
>
> Share the clipboard of your computer with other computers on a local
> network with Clipboard Link
> http://clipbaordlink.economy-x-talk.com
>
> Op 10 apr 2010, om 20:28 heeft Peter Brigham MD het volgende
> geschreven:
>>
>> The code above will find and replace the first occurrence of the
>> string. For access to all the occurrences, use this handler:
>>
>> function offsets str,cntr
>> -- returns a comma-delimited list
>> -- of all the offsets of str in cntr
>> if str is not in cntr then return 0
>> put "" into offsetList
>> put 0 into startPoint
>> repeat
>> put offset(str,cntr,startPoint) into thisOffset
>> if thisOffset = 0 then exit repeat
>> add thisOffset to startPoint
>> put startPoint & comma after offsetList
>> end repeat
>> delete last char of offsetList
>> return offsetList
>> end offsets
>>
>> -- Peter
>>
>> Peter M. Brigham
>> pmbrig at gmail.com
>> http://home.comcast.net/~pmbrig
>>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list