Re: creating your own commands
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