AppleScript名:CotEditorの最前面のドキュメントの内容から前後にある空白文字列をトリミングして文字リスト化 |
use AppleScript version "2.5" use scripting additions use framework "Foundation" property NSString : a reference to current application’s NSString property NSCharacterSet : a reference to current application’s NSCharacterSet tell application "CotEditor" tell front document set aCon to contents end tell end tell set aList to paragraphs of aCon set outList to {} repeat with i in aList set j to trimWhiteSpaceFromHeadAndTail(i) of me set the end of outList to j end repeat outList –指定文字列の前後から空白をトリミング on trimWhiteSpaceFromHeadAndTail(aStr as string) set aString to NSString’s stringWithString:aStr set bString to aString’s stringByTrimmingCharactersInSet:(NSCharacterSet’s whitespaceAndNewlineCharacterSet()) return bString as list of string or string –as anything end trimWhiteSpaceFromHeadAndTail |
More from my site
(Visited 52 times, 1 visits today)