diff --git a/Sources/_StringProcessing/Regex/Options.swift b/Sources/_StringProcessing/Regex/Options.swift index c66502d96..88d2dbf5d 100644 --- a/Sources/_StringProcessing/Regex/Options.swift +++ b/Sources/_StringProcessing/Regex/Options.swift @@ -12,7 +12,7 @@ @_implementationOnly import _RegexParser @available(SwiftStdlib 5.7, *) -extension RegexComponent { +extension Regex { /// Returns a regular expression that ignores case when matching. /// /// - Parameter ignoresCase: A Boolean value indicating whether to ignore case. diff --git a/Tests/RegexBuilderTests/RegexDSLTests.swift b/Tests/RegexBuilderTests/RegexDSLTests.swift index 74e278a31..5fd54c242 100644 --- a/Tests/RegexBuilderTests/RegexDSLTests.swift +++ b/Tests/RegexBuilderTests/RegexDSLTests.swift @@ -238,8 +238,10 @@ class RegexDSLTests: XCTestCase { ("abcabc", "abcabc"), ("abcABCaBc", "abcABCaBc"), matchType: Substring.self, ==) { - OneOrMore { - "abc" + Regex { + OneOrMore { + "abc" + } }.ignoresCase(true) } @@ -251,8 +253,10 @@ class RegexDSLTests: XCTestCase { ("abcabc", "abcabc"), ("abcABCaBc", "abcABCaBc"), matchType: Substring.self, ==) { - OneOrMore { - "abc" + Regex { + OneOrMore { + "abc" + } } .ignoresCase(true) .ignoresCase(false) @@ -268,9 +272,13 @@ class RegexDSLTests: XCTestCase { ("abcabc", "abcabc"), ("abcdeABCdeaBcde", "abcdeABCdeaBcde"), matchType: Substring.self, ==) { - OneOrMore { - "abc".ignoresCase(true) - Optionally("de") + Regex { + OneOrMore { + Regex { + "abc" + }.ignoresCase(true) + Optionally("de") + } } .ignoresCase(false) } @@ -307,11 +315,13 @@ class RegexDSLTests: XCTestCase { "stop" " " - Capture { - OneOrMore(.word) - Anchor.wordBoundary - } - .wordBoundaryKind(.simple) + Regex { + Capture { + OneOrMore(.word) + Anchor.wordBoundary + } + }.wordBoundaryKind(.simple) + OneOrMore(.any, .reluctant) "stop" } @@ -321,15 +331,17 @@ class RegexDSLTests: XCTestCase { matchType: (Substring, Substring, Substring).self, ==) { Capture { // Reluctant behavior due to option - OneOrMore(.anyOf("abcd")) - .repetitionBehavior(.reluctant) + Regex { + OneOrMore(.anyOf("abcd")) + }.repetitionBehavior(.reluctant) } ZeroOrMore("a"..."z") Capture { // Eager behavior due to explicit parameter, despite option - OneOrMore(.digit, .eager) - .repetitionBehavior(.reluctant) + Regex { + OneOrMore(.digit, .eager) + }.repetitionBehavior(.reluctant) } ZeroOrMore(.digit) } @@ -338,10 +350,11 @@ class RegexDSLTests: XCTestCase { ("abcdefg", ("abcdefg", "abcdefg")), ("abcdéfg", ("abcdéfg", "abcd")), matchType: (Substring, Substring).self, ==) { - Capture { - OneOrMore(.word) - } - .asciiOnlyWordCharacters() + Regex { + Capture { + OneOrMore(.word) + } + }.asciiOnlyWordCharacters() ZeroOrMore(.any) } @@ -372,8 +385,10 @@ class RegexDSLTests: XCTestCase { ("abc1def2", ("abc1def2", "1")), matchType: (Substring, Substring).self, ==) { - OneOrMore(.reluctant) { - One(.word) + Regex { + OneOrMore(.reluctant) { + One(.word) + } }.repetitionBehavior(.possessive) Capture(.digit) ZeroOrMore(.any) @@ -425,8 +440,9 @@ class RegexDSLTests: XCTestCase { { Regex { Capture { - OneOrMore("a") - .repetitionBehavior(.eager) + Regex { + OneOrMore("a") + }.repetitionBehavior(.eager) } OneOrMore("a") }.repetitionBehavior(.possessive) @@ -438,8 +454,9 @@ class RegexDSLTests: XCTestCase { { Regex { Capture { - OneOrMore("a") - .repetitionBehavior(.reluctant) + Regex { + OneOrMore("a") + }.repetitionBehavior(.reluctant) } OneOrMore("a") }.repetitionBehavior(.possessive)