Previous Index Next

BridgePlus.framework, SMSForder Class Methods

Category

Regular Expression methods

Method

findMatches:inString:options:captureGroups:

Summary

 

Signature

+ (NSArray *)findMatches:(NSString *)regexPattern inString:(NSString *)searchString options:(NSString *)optionsString captureGroups:(NSArray *)arrayOfIntegers

Parameters

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

Result

Returns an array for each match, sorted in your specified capture group order. If you specify non-existent capture groups or capture groups that do not participate in a particular match, they will be represented by missing value. If no matches are found, the overall result will be missing value.

Availability

Version 1.0.0

Notes

 

Sample

use scripting additions

use framework "Foundation"

use script "BridgePlus"

load framework


set aString to "The price is $39.99"

set theResult to current application's SMSForder's findMatches:"(\\d+)\\.(\\d+)" inString:aString options:"" captureGroups:{0, 1, 2}

ASify from theResult

--> {{"39.33", "39", "33"}}

theResult as list

--> {{"39.33", "39", "33"}}

set aString to "The price is $39.99, normally $49.99"


set theResult to current application's SMSForder's findMatches:"(\\d+)\\.(\\d+)" inString:aString options:"" captureGroups:{1, 2}

ASify from theResult

--> {{"39", "99"}, {"49", "99"}}

theResult as list

--> {{"39", "99"}, {"49", "99"}}


Click here to open script in a script editor