Skip to content

Commit 60303e1

Browse files
committed
Conform Substring to RegexProtocol
1 parent 883d358 commit 60303e1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Sources/_StringProcessing/RegexDSL/DSL.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ extension String: RegexProtocol {
2222
}
2323
}
2424

25+
extension Substring: RegexProtocol {
26+
public typealias Match = Substring
27+
28+
public var regex: Regex<Match> {
29+
let atoms = self.map { atom(.char($0)) }
30+
return .init(ast: concat(atoms))
31+
}
32+
}
33+
2534
extension Character: RegexProtocol {
2635
public typealias Match = Substring
2736

0 commit comments

Comments
 (0)