File tree Expand file tree Collapse file tree 2 files changed +24
-14
lines changed Expand file tree Collapse file tree 2 files changed +24
-14
lines changed Original file line number Diff line number Diff line change @@ -107,16 +107,26 @@ extension Anchor {
107107 }
108108}
109109
110- public func lookahead< R: RegexComponent > (
111- negative: Bool = false ,
112- @RegexComponentBuilder _ content: ( ) -> R
113- ) -> Regex < R . Output > {
114- Regex ( node: . nonCapturingGroup( negative ? . negativeLookahead : . lookahead, content ( ) . regex. root) )
115- }
116-
117- public func lookahead< R: RegexComponent > (
118- _ component: R ,
119- negative: Bool = false
120- ) -> Regex < R . Output > {
121- Regex ( node: . nonCapturingGroup( negative ? . negativeLookahead : . lookahead, component. regex. root) )
110+ public struct Lookahead < Output> : _BuiltinRegexComponent {
111+ public var regex : Regex < Output >
112+
113+ init ( _ regex: Regex < Output > ) {
114+ self . regex = regex
115+ }
116+
117+ public init < R: RegexComponent > (
118+ _ component: R ,
119+ negative: Bool = false
120+ ) where R. Output == Output {
121+ self . init ( node: . nonCapturingGroup(
122+ negative ? . negativeLookahead : . lookahead, component. regex. root) )
123+ }
124+
125+ public init < R: RegexComponent > (
126+ negative: Bool = false ,
127+ @RegexComponentBuilder _ component: ( ) -> R
128+ ) where R. Output == Output {
129+ self . init ( node: . nonCapturingGroup(
130+ negative ? . negativeLookahead : . lookahead, component ( ) . regex. root) )
131+ }
122132}
Original file line number Diff line number Diff line change @@ -306,8 +306,8 @@ class RegexDSLTests: XCTestCase {
306306 matchType: Substring . self, == )
307307 {
308308 OneOrMore ( " a " )
309- lookahead ( CharacterClass . digit)
310- lookahead ( " 2 " , negative: true )
309+ Lookahead ( CharacterClass . digit)
310+ Lookahead ( " 2 " , negative: true )
311311 CharacterClass . word
312312 }
313313 }
You can’t perform that action at this time.
0 commit comments