# RegexPattern

- **Package:** libtmux-swift
- **Language:** Swift
- **Kind:** struct
- **Source:** https://github.com/libtmux/libtmux-swift/blob/f02a4668570e1cc5198c941413750e021f42c214/Sources/LibTmux/RegexPattern.swift#L54
- **Page:** https://libtmux.org/reference/swift/regexpattern/

A compiled regular expression with bounded memory and matching work.

The supported dialect has literals, escaped punctuation, `.`, `^`, `$`,
grouping, noncapturing grouping, alternation, `*`, `+`, `?`, counted
repetitions, character classes and ranges, and ASCII `\d`, `\s`, and
`\w` shorthands. Lookaround and backreferences are rejected.

Matching consumes Swift extended grapheme clusters. Literal equality uses
Swift `Character` equality, including canonical equivalence. With
``Options/caseInsensitive``, each character is compared through
locale-independent `lowercased()` values; full multi-character case folding
is not performed, so `ss` does not match `ß`. Dot excludes line terminators.

Swift's own `Regex` cannot take this job. Its matcher backtracks — on Swift
6.2, `(a+)+b` against twenty `a`s takes 78 seconds — and a match is
synchronous, so the deadline ``Server/waitForOutput(in:matching:stoppingAt:requiringFreshOutput:timeout:tailLimit:)``
races cannot interrupt one that has started. A pattern here is bounded
before it runs, which is also what makes one safe to accept from a client.

## Members

- `!=(_:_:)` (function) — Returns a Boolean value indicating whether two values are not equal.
- `Options` (struct) — Matching options encoded with the pattern.
- `maximumSourceUTF8Bytes` (property)
- `maximumNesting` (property)
- `maximumCompiledStates` (property)
- `maximumRepetition` (property)
- `maximumInputUTF8Bytes` (property)
- `defaultMaximumWork` (property)
- `source` (property) — The source form preserved for encoding and diagnostics.
- `options` (property) — Options applied during matching.
- `init(_:options:)` (method) — Compiles a bounded regular expression.
- `containsMatch(in:maximumWork:)` (method) — Returns whether the expression occurs in `input` before its positive work budget.
- `==(_:_:)` (function) — Returns a Boolean value indicating whether two values are equal.
- `hash(into:)` (method) — Hashes the essential components of this value by feeding them into the given hasher.
- `init(from:)` (method) — Creates a new instance by decoding from the given decoder.
- `encode(to:)` (method) — Encodes this value into the given encoder.
