• 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: Missing ampersand
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Missing ampersand


  • Subject: Re: Missing ampersand
  • From: Shane Stanley <email@hidden>
  • Date: Sat, 25 Mar 2017 21:56:55 +1100

On 25 Mar 2017, at 10:33 am, Christopher Stone <email@hidden> wrote:

AppleScriptObjC works quite well for this as well and returns the same result.  (This is equivalent to using AppleScript's text item delimiters.)

Yes, although the equivalent to your other handlers, which split on any white space characters including line breaks, would be:

use framework "Foundation"
use scripting additions

set theString to "eric v smith & jones"

set stringComponentList to my splitOnAnySpace:theString

on splitOnAnySpace:someText -- free to a good home
set theString to current application's NSString's stringWithString:someText
set theList to theString's componentsSeparatedByCharactersInSet:(current application's NSCharacterSet's whitespaceAndNewlineCharacterSet())
return theList as list
end splitOnAnySpace:

Or roughly:

use framework "Foundation"
use scripting additions

set theString to "eric v smith & jones"

set stringComponentList to my splitString:theString atCharactersInString:(linefeed & return & tab & space)

on splitString:someText atCharactersInString:stringOfChars -- free to a good home
set theString to current application's NSString's stringWithString:someText
set theList to theString's componentsSeparatedByCharactersInSet:(current application's NSCharacterSet's characterSetWithCharactersInString:stringOfChars)
return theList as list
end splitString:atCharactersInString:

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


 _______________________________________________
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

  • Follow-Ups:
    • Re: Missing ampersand
      • From: Jeremy Roussak <email@hidden>
    • Re: Missing ampersand
      • From: Christopher Stone <email@hidden>
References: 
 >Missing ampersand (From: Jeremy Roussak <email@hidden>)
 >Re: Missing ampersand (From: Yvan KOENIG <email@hidden>)
 >Re: Missing ampersand (From: Jeremy Roussak <email@hidden>)
 >Re: Missing ampersand (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Lists to XML ?
  • Next by Date: Re: Lists to XML ?
  • Previous by thread: Re: Missing ampersand
  • Next by thread: Re: Missing ampersand
  • Index(es):
    • Date
    • Thread