Re: cutting multiple sections from a string?
Re: cutting multiple sections from a string?
- Subject: Re: cutting multiple sections from a string?
- From: Shane Stanley <email@hidden>
- Date: Tue, 03 Sep 2013 15:49:14 +1000
On 03/09/2013, at 2:33 PM, Alex Hall <email@hidden> wrote:
> I need a way to remove chunks from a string given the string and the sets of numbers, like {{1,3}, {8,16}}.
on removeChunks_inString_(rangeList, theString)
set rangeList to reverse of rangeList
repeat with aRange in rangeList
if item 1 of aRange = 1 then
set theString to text ((item 2 of aRange) + 1) thru -1 of theString
else if item 2 of aRange = (length of theString) then
set theString to text 1 thru ((item 1 of aRange) - 1) of theString
else
set theString to text 1 thru ((item 1 of aRange) - 1) of theString & text ((item 2 of aRange) + 1) thru -1 of theString
end if
end repeat
end removeChunks_inString_
removeChunks_inString_({{1, 3}, {8, 16}}, "I need a way to remove chunks from a string given the string and the sets of numbers")
It needs error checking, basically that item 2 of aRange is no greater than the string's length.
> Any suggestions will be great
AppleScript isn't javascript or any other language, and if you keep trying to emulate them, you're just making a rod for your back.
Why use strings for if statements? Sounds like a severe case of masochism to me...
--
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden