ChoiceOf
A regex component that chooses exactly one of its constituent regex components when matching.
Declaration
struct ChoiceOf<Output>Overview
You can use ChoiceOf to provide a group of regex components, each of which can be exclusively matched. In this example, regex successfully matches either a "CREDIT" or "DEBIT" substring:
let regex = Regex {
ChoiceOf {
"CREDIT"
"DEBIT"
}
}
let match = try regex.prefixMatch(in: "DEBIT 04032020 Payroll $69.73")
print(match?.0 as Any)
// Prints "DEBIT"