Instance Method

matchesInString:options:range:

Returns an array containing all the matches of the regular expression in the string.

Declaration

- (NSArray<NSTextCheckingResult *> *)matchesInString:(NSString *)string options:(NSMatchingOptions)options range:(NSRange)range;

Parameters

string

The string to search.

options

The matching options to use. See NSMatchingOptions for possible values.

range

The range of the string to search.

Return Value

An array of NSTextCheckingResult objects. Each result gives the overall matched range via its range property, and the range of each individual capture group via its rangeAtIndex: method. The range {NSNotFound, 0} is returned if one of the capture groups did not participate in this particular match.

Discussion

This is a convenience method that calls enumerateMatchesInString:options:range:usingBlock: passing the appropriate string, options, and range.

See Also

Searching Strings Using Regular Expressions

- numberOfMatchesInString:options:range:

Returns the number of matches of the regular expression within the specified range of the string.

- enumerateMatchesInString:options:range:usingBlock:

Enumerates the string allowing the Block to handle each regular expression match.

- firstMatchInString:options:range:

Returns the first match of the regular expression within the specified range of the string.

- rangeOfFirstMatchInString:options:range:

Returns the range of the first match of the regular expression within the specified range of the string.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software