RegexBuilder DSL
Compose regexes with a readable builder.
RegexBuilder DSL
Complex regex literals get hard to read. The RegexBuilder module lets you build patterns from Swift code using a result-builder DSL, with named components and types.
Importing RegexBuilder
Import the module, then construct a Regex with the Regex { ... } builder. Inside, each line is a sequential part of the pattern.
import RegexBuilder
let re = Regex {
"ID-"
OneOrMore(.digit)
}
print("ID-42".contains(re))