---
title: "matches(in:options:range:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsregularexpression/matches(in:options:range:)"
---

# matches(in:options:range:)

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

## Declaration

```swift
func matches(in string: String, options: NSRegularExpression.MatchingOptions = [], range: NSRange) -> [NSTextCheckingResult]
```

## Parameters

- `string`: The string to search.
- `options`: The matching options to use. See doc://com.apple.foundation/documentation/Foundation/NSRegularExpression/MatchingOptions for possible values.
- `range`: The range of the string to search.

## Return Value

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 range(at:) method. The range {NSNotFound, 0} is returned if one of the capture groups did not participate in this particular match.

## Discussion

Discussion This is a convenience method that calls enumerateMatches(in:options:range:using:) passing the appropriate string, options, and range.

## See Also

### Searching Strings Using Regular Expressions

- [numberOfMatches(in:options:range:)](foundation/nsregularexpression/numberofmatches(in:options:range:).md)
- [enumerateMatches(in:options:range:using:)](foundation/nsregularexpression/enumeratematches(in:options:range:using:).md)
- [firstMatch(in:options:range:)](foundation/nsregularexpression/firstmatch(in:options:range:).md)
- [rangeOfFirstMatch(in:options:range:)](foundation/nsregularexpression/rangeoffirstmatch(in:options:range:).md)
