AppleScript名:与えられたテキストからリンクURLを抽出 v3 |
— Created 2015-08-21 by Shane Stanley — Modified 2015-08-21 by Takaaki Naganoya — Modified 2015-08-22 by Shane Stanley — Modified 2015-08-23 by Takaaki Naganoya 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 resList to (extractLinksFromNaturalText(theString)) –> {(NSURL) mailto:maro@piyocast.com, (NSURL) http://piyocast.com/as} set bList to {} repeat with i in resList set the end of bList to (i’s absoluteString()) as text end repeat bList –> {"mailto:maro@piyocast.com", "http://piyocast.com/as"} on extractLinksFromNaturalText(aString) set anNSString to current application’s NSString’s stringWithString:aString set {theDetector, theError} to current application’s NSDataDetector’s dataDetectorWithTypes:(current application’s NSTextCheckingTypeLink) |error|:(reference) set theMatches to theDetector’s matchesInString:anNSString options:0 range:{0, anNSString’s |length|()} set theResults to theMatches’s valueForKey:"URL" return theResults as list end extractLinksFromNaturalText |
More from my site
(Visited 33 times, 1 visits today)