<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/BidirectionalCollection/wholeMatch(of:)-7741n",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SK17_StringProcessingSs11SubSequenceRtzrlE10wholeMatch2ofAA5RegexV0F0Vy0H6OutputQyd___GSgqd___tAA0H9ComponentRd__lF"
  },
  "title" : "wholeMatch(of:)"
}
-->

# wholeMatch(of:)

Returns a match if this string is matched by the given regex in its entirety.

```
func wholeMatch<R>(of regex: R) -> Regex<R.RegexOutput>.Match? where R : RegexComponent
```

## Parameters

`regex`

The regular expression to match.

## Return Value

The match, if one is found. If there is no match, or a
transformation in `regex` throws an error, this method returns `nil`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)