<!--
{
  "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/Regex/repetitionBehavior(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:17_StringProcessing5RegexV18repetitionBehavioryACyxGAA0c10RepetitionE0VF"
  },
  "title" : "repetitionBehavior(_:)"
}
-->

# repetitionBehavior(_:)

Returns a regular expression where quantifiers use the specified behavior
by default.

```
func repetitionBehavior(_ behavior: RegexRepetitionBehavior) -> Regex<Regex<Output>.RegexOutput>
```

## Parameters

`behavior`

The default behavior to use for quantifiers.

## Discussion

This setting does not affect calls to quantifier methods, such as
`OneOrMore`, that include an explicit `behavior` parameter.

Passing `.eager` or `.reluctant` to this method corresponds to applying
the `(?-U)` or `(?U)` option in regex syntax, respectively.

---

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)