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日 080-1111-2222 東京都練馬区中村橋1-2-3 " set theDates to (extractPhoneNumberFromNaturalText(theString)) –> {"080-1111-2222"} on extractPhoneNumberFromNaturalText(aString) set anNSString to current application’s NSString’s stringWithString:aString set {theDetector, theError} to current application’s NSDataDetector’s dataDetectorWithTypes:(current application’s NSTextCheckingTypePhoneNumber) |error|:(reference) set theMatches to theDetector’s matchesInString:anNSString options:0 range:{0, anNSString’s |length|()} set theResults to theMatches’s valueForKey:"phoneNumber" return theResults as list end extractPhoneNumberFromNaturalText |
More from my site
(Visited 38 times, 1 visits today)