Previous | Index | Next |
Regular Expression methods
findMatches:inString:options:
Returns an array of the matching strings found. If none found, returns an empty array.
+ (NSArray *)findMatches:(NSString *)regexPattern inString:(NSString *)searchString options:(NSString *)optionsString
regexPattern = ICY regular expression pattern; see http://userguide.icu-project.org/strings/regexp.
searchString = string to search
optionsString = a string containing any or all of the following letters:
i Makes the search case insensitive
x Allows white space and #comments in the pattern
s Makes the "." character match a line terminator
m Makes "^" and "$" match the start/end of every line, not just the whole string
w Makes \b match word boundaries as described in Unicode UAX 29, rather than traditional regular expression behavior
Array of found strings.
Version 1.0.0
use scripting additions
use framework "Foundation"
use script "BridgePlus"
load framework
set aString to "The cat sat in the cot"
set theResult to current application's SMSForder's findMatches:"c.t" inString:aString options:""
ASify from theResult
--> {"cat", "cot"}
theResult as list -- only in 10.10 and later
--> {"cat", "cot"}
set theResult to current application's SMSForder's findMatches:"th." inString:aString options:""
ASify from theResult
--> {"the"}
theResult as list
--> {"the"}
set theResult to current application's SMSForder's findMatches:"th." inString:aString options:"i"
ASify from theResult
--> {"The", "the"}
theResult as list
--> {"The", "the"}