AppleScript名:与えられたテキストから住所を抽出 v2 |
— Created 2015-08-21 by Shane Stanley — Modified 2015-08-21 by Takaaki Naganoya — Modified 2015-08-22 by Shane Stanley use AppleScript version "2.4" use scripting additions use framework "Foundation" set theString to "長野谷隆昌 (Takaaki Naganoya) maro@piyocast.com http://piyocast.com/as 2015年8月21日〜23日 東京都練馬区中村橋1-2-3 " set theDates to (extractAddressFromNaturalText(theString)) –> {{State:"東京都", Street:"中村橋1-2-3", City:"練馬区"}} on extractAddressFromNaturalText(aString) set anNSString to current application’s NSString’s stringWithString:aString set {theDetector, theError} to current application’s NSDataDetector’s dataDetectorWithTypes:(current application’s NSTextCheckingTypeAddress) |error|:(reference) set theMatches to theDetector’s matchesInString:anNSString options:0 range:{0, anNSString’s |length|()} set theResults to theMatches’s valueForKey:"addressComponents" return theResults as list end extractAddressFromNaturalText |
More from my site
(Visited 17 times, 1 visits today)