• 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: creating your own commands
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: creating your own commands


  • Subject: Re: creating your own commands
  • From: Yvan KOENIG <email@hidden>
  • Date: Thu, 24 Dec 2015 15:54:14 +0100


Maybe it would be fine to add this Shane Stanley's handler which like yours remove space and newline characters at the beginning and end of the passed string but also replace groups of space characters by single one.

use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
on cleanUpText:someText
set theString to current application's NSString's stringWithString:someText
set stringLength to theString's |length|()
set theString to theString's stringByReplacingOccurrencesOfString:" +" withString:" " options:(current application's NSRegularExpressionSearch) range:{location:0, |length|:stringLength}
set theWhiteSet to current application's NSCharacterSet's whitespaceAndNewlineCharacterSet()
set theString to theString's stringByTrimmingCharactersInSet:theWhiteSet
return theString as text
end cleanUpText:



Yvan KOENIG running El Capitan 10.11.2 in French (VALLAURIS, France) jeudi 24 décembre 2015 15:54:10


 _______________________________________________
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: creating your own commands
      • From: 2551 <email@hidden>
References: 
 >creating your own commands (From: 2551 <email@hidden>)
 >Re: creating your own commands (From: 2551 <email@hidden>)
 >Re: creating your own commands (From: Yvan KOENIG <email@hidden>)
 >Re: creating your own commands (From: 2551 <email@hidden>)
 >Re: creating your own commands (From: 2551 <email@hidden>)

  • Prev by Date: Re: creating your own commands
  • Next by Date: Re: creating your own commands
  • Previous by thread: Re: creating your own commands
  • Next by thread: Re: creating your own commands
  • Index(es):
    • Date
    • Thread