AppleScript名:与えられたテキストからメールアドレスを抽出する |
— Created 2017-01-13 by Shane Stanley — Modified 2017-01-13 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" set aText to " — Takaaki Naganoya Piyomaru Software http://piyocast.com/as maro@piyocast.com " set aRes to findEmailAddressesIn(aText) of me –> {"maro@piyocast.com"} on findEmailAddressesIn(someString) set theDD to current application’s NSDataDetector’s dataDetectorWithTypes:(current application’s NSTextCheckingTypeLink) |error|:(missing value) set theURLs to theDD’s matchesInString:someString options:0 range:{location:0, |length|:length of someString} set thePredicate to current application’s NSPredicate’s predicateWithFormat:"self.URL.scheme == ’mailto’" set theURLs to theURLs’s filteredArrayUsingPredicate:thePredicate set theURLs to theURLs’s valueForKeyPath:"URL.resourceSpecifier" set theURLs to (current application’s NSSet’s setWithArray:theURLs)’s allObjects() return theURLs as list end findEmailAddressesIn |
More from my site
(Visited 14 times, 1 visits today)