• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sorting IP addresses
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Sorting IP addresses (From: Marconi <email@hidden>)
 >Re: Sorting IP addresses (From: Steve Mills <email@hidden>)
 >Re: Sorting IP addresses (From: Graff <email@hidden>)
 >Re: Sorting IP addresses (From: Marconi <email@hidden>)
 >Re: Sorting IP addresses (From: Emmanuel <email@hidden>)
 >Re: Sorting IP addresses (From: Marconi <email@hidden>)

  • Prev by Date: Pinging
  • Next by Date: Re: [OT] Airport card device name
  • Previous by thread: Re: Sorting IP addresses
  • Next by thread: Re: Sorting IP addresses
  • Index(es):
    • Date
    • Thread