RegexPattern
A compiled regular expression with bounded memory and matching work.
Source and package
- Qualified name
-
RegexPattern - Package
- libtmux-swift
- Source
- Sources/LibTmux/RegexPattern.swift
- struct RegexPattern : struct Regex
Pattern -
Description#
The supported dialect has literals, escaped punctuation,
.,^,$, grouping, noncapturing grouping, alternation,*,+,?, counted repetitions, character classes and ranges, and ASCII\d,\s, and\wshorthands. Lookaround and backreferences are rejected.Matching consumes Swift extended grapheme clusters. Literal equality uses Swift
Characterequality, including canonical equivalence. WithOptions.caseInsensitive, each character is compared through locale-independentlowercased()values; full multi-character case folding is not performed, sossdoes not matchß. Dot excludes line terminators.Swift's own
Regexcannot take this job. Its matcher backtracks — on Swift 6.2,(a+)+bagainst twentyas takes 78 seconds — and a match is synchronous, so the deadlineServer.waitForOutput(in:matching:stoppingAt:requiringFreshOutput:startingAt: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.
Members15#
- ==(_:_:) function Returns a Boolean value indicating whether two values are equal.
- containsMatch(in:maximumWork:) method Returns whether the expression occurs in
inputbefore its positive work budget. - defaultMaximumWork: static let default
Maximum : Int propertyWork - encode(to:) method Encodes this value into the given encoder.
- hash(into:) method Hashes the essential components of this value by feeding them into the given hasher.
- init(_:options:) method Compiles a bounded regular expression.
- init(from:) method Creates a new instance by decoding from the given decoder.
- maximumCompiledStates: static let maximum
Compiled : Int propertyStates - maximumInputUTF8Bytes: static let maximum
Input : Int propertyUTF8Bytes - maximumNesting: static let maximum
Nesting : Int property - maximumRepetition: static let maximum
Repetition : Int property - maximumSourceUTF8Bytes: static let maximum
Source : Int propertyUTF8Bytes - options: let options: Options property Options applied during matching.
- Options: struct Options struct Matching options encoded with the pattern.
- source: let source: String property The source form preserved for encoding and diagnostics.
Inherited members1 member#
Reached through Equatable.!=(_:_:).