On 13 Jan 2017, at 6:45 am, Jacob Small <
email@hidden> wrote:
Is there an easier way to do this?
There are more efficient ways. For example:
on removeLigaturesFromString(inputStringWithLigatures)
set searchStrings to {"Ꜳ", "ꜳ"} -- add the rest here
set replaceStrings to {"AA", "aa"} -- add the rest here
set saveTID to AppleScript's text item delimiters
considering case
repeat with i from 1 to count of searchStrings
set AppleScript's text item delimiters to {item i of searchStrings}
set inputStringWithLigatures to text items of inputStringWithLigatures
set AppleScript's text item delimiters to {item i of replaceStrings}
set inputStringWithLigatures to inputStringWithLigatures as text
end repeat
end considering
set AppleScript's text item delimiters to saveTID
return replaceStrings
end removeLigaturesFromString
Here's an alternative for extracting the email addresses:
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
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 theContent}
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:
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives:
http://lists.apple.com/archives/applescript-users
This email sent to email@hidden