------------------------------------------------------------------------------
use framework "Foundation"
use scripting additions
set theString to "eric v smith & jones"
set stringComponentList to my reMatch:"\\S+" inText:theString
------------------------------------------------------------------------------
--» HANDLERS
------------------------------------------------------------------------------
on reMatch:findPattern inText:theText
set theNSString to current application's NSString's stringWithString:theText
set theOptions to ((current application's NSRegularExpressionDotMatchesLineSeparators) as integer) + ((current application's NSRegularExpressionAnchorsMatchLines) as integer)
set theRegEx to current application's NSRegularExpression's regularExpressionWithPattern:findPattern options:theOptions |error|:(missing value)
set theFinds to theRegEx's matchesInString:theNSString options:0 range:{location:0, |length|:theNSString's |length|()}
set theFinds to theFinds as list -- so we can loop through
set theResult to {} -- we will add to this
repeat with i from 1 to count of items of theFinds
set theRange to (item i of theFinds)'s range()
set end of theResult to (theNSString's substringWithRange:theRange) as string
end repeat
return theResult
end reMatch:inText:
------------------------------------------------------------------------------
Tags: @AppleScript, @Script, @ASObjC, @ccstone, @RegEx, @Match, @String, @Find