---
title: "init(_:_:)"
framework: regexbuilder
role: symbol
role_heading: Initializer
path: "regexbuilder/optionally/init(_:_:)-83pgy"
---

# init(_:_:)

Creates a regex component that matches the given component zero or one times.

## Declaration

```swift
init<W, C1, C2, C3, C4, C5, C6, C7, C8, C9>(_ component: some RegexComponent, _ behavior: RegexRepetitionBehavior? = nil) where Output == (Substring, C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?, C9?)
```

## Parameters

- `component`: The regex component.
- `behavior`: The repetition behavior to use when repeating component in the match. If behavior is nil, the default repetition behavior is used, which can be changed from eager by calling repetitionBehavior(_:) on the resulting Regex.
