Re: Sorting IP addresses
Re: Sorting IP addresses
- Subject: Re: Sorting IP addresses
- From: Emmanuel <email@hidden>
- Date: Fri, 19 Dec 2003 08:54:23 +0100
At 11:53 PM -0700 18/12/03, Marconi wrote:
>
At 9:21 PM +0100 12/18/03, Emmanuel wrote:
>
>
>
>You could download Smile (4.3 MB) and install it. Then, assuming your list is a list of string l:
>
>
This may very well work but is not exactly my idea of automation....
You're right. The approach I have suggested is more like a gradual way of making your script, where you would test it as you write it - an approach that I would recommend to beginners in AppleScript.
If you feel more like writing your script blind, here would be my suggestion.
-- suppose the list is stored in "l"
tid(return)
set s to (l as text) -- make the list a string to prepend zero's
set s to change "(^|\\.)([0-9])(\\.|$)" into "\\100\\2\\3" in s with regexp
set s to change "(^|\\.)([0-9]{2})(\\.|$)" into "\\10\\2\\3" in s with regexp
set l to text items of s -- make the text a list to sort it
set l to sort(l)
set s to (l as text) -- make the list a string to remove leading zero's
set s to change "(^|\\.)[0]+" into "\\1" in s with regexp
set l to text items of s -- we're done
tid("") -- let's be clean, we are on a mailing list
And, I agree, that's definitely shorter, however to test that script I did exactly what I had suggested to you in the first place.
Emmanuel
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.