Skip to content

Commit 8a40f4f

Browse files
committed
Rename various APIs
remove input doc fixes remove dot
1 parent 7752047 commit 8a40f4f

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

Sources/RegexBuilder/Anchor.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ extension Anchor {
104104
///
105105
/// This anchor is equivalent to `^` in regex syntax when the `m` option
106106
/// has been enabled or `anchorsMatchLineEndings(true)` has been called.
107+
///
108+
/// For example, the following regexes are all equivalent:
109+
/// - `Regex { Anchor.startOfLine }`
110+
/// - `/(?m)^/` or `/(?m:^)/`
111+
/// - `/^/.anchorsMatchLineEndings(true)`
107112
public static var startOfLine: Anchor {
108113
Anchor(kind: .startOfLine)
109114
}
@@ -113,6 +118,11 @@ extension Anchor {
113118
///
114119
/// This anchor is equivalent to `$` in regex syntax when the `m` option
115120
/// has been enabled or `anchorsMatchLineEndings(true)` has been called.
121+
///
122+
/// For example, the following regexes are all equivalent:
123+
/// - `Regex { Anchor.endOfLine }`
124+
/// - `/(?m)$/` or `/(?m:$)/`
125+
/// - `/$/.anchorsMatchLineEndings(true)`
116126
public static var endOfLine: Anchor {
117127
Anchor(kind: .endOfLine)
118128
}

Sources/_StringProcessing/Regex/Options.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ extension RegexComponent {
6565
/// - Parameter wordBoundaryKind: The algorithm to use for determining word boundaries.
6666
/// - Returns: The modified regular expression.
6767
public func wordBoundaryKind(_ wordBoundaryKind: RegexWordBoundaryKind) -> Regex<RegexOutput> {
68-
wrapInOption(.unicodeWordBoundaries, addingIf: wordBoundaryKind == .unicodeLevel2)
68+
wrapInOption(.unicodeWordBoundaries, addingIf: wordBoundaryKind == .default)
6969
}
7070

7171
/// Returns a regular expression where the start and end of input
@@ -83,8 +83,8 @@ extension RegexComponent {
8383
///
8484
/// This method corresponds to applying the `m` option in regex syntax. For
8585
/// this behavior in the `RegexBuilder` syntax, see
86-
/// ``Anchor.startOfLine``, ``Anchor.endOfLine``, ``Anchor.startOfInput``,
87-
/// and ``Anchor.endOfInput``.
86+
/// ``Anchor.startOfLine``, ``Anchor.endOfLine``, ``Anchor.startOfSubject``,
87+
/// and ``Anchor.endOfSubject``.
8888
///
8989
/// - Parameter matchLineEndings: A Boolean value indicating whether `^` and
9090
/// `$` should match the start and end of lines, respectively.
@@ -205,7 +205,7 @@ public struct RegexWordBoundaryKind: Hashable {
205205
/// that match `/\w\W/` or `/\W\w/`, or between the start or end of the input
206206
/// and a `\w` character. Word boundaries therefore depend on the option-
207207
/// defined behavior of `\w`.
208-
public static var unicodeLevel1: Self {
208+
public static var simple: Self {
209209
.init(base: .unicodeLevel1)
210210
}
211211

@@ -215,7 +215,7 @@ public struct RegexWordBoundaryKind: Hashable {
215215
/// Default word boundaries use a Unicode algorithm that handles some cases
216216
/// better than simple word boundaries, such as words with internal
217217
/// punctuation, changes in script, and Emoji.
218-
public static var unicodeLevel2: Self {
218+
public static var `default`: Self {
219219
.init(base: .unicodeLevel2)
220220
}
221221
}

Tests/RegexBuilderTests/RegexDSLTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ class RegexDSLTests: XCTestCase {
311311
OneOrMore(.word)
312312
Anchor.wordBoundary
313313
}
314-
.wordBoundaryKind(.unicodeLevel1)
314+
.wordBoundaryKind(.simple)
315315
OneOrMore(.any, .reluctant)
316316
"stop"
317317
}
@@ -675,7 +675,7 @@ class RegexDSLTests: XCTestCase {
675675
Regex {
676676
Anchor.startOfSubject
677677
Repeat("a", count: 3)
678-
Anchor.endOfSubject
678+
Anchor.endOfInput
679679
}.anchorsMatchLineEndings()
680680
}
681681

Tests/RegexTests/UTS18Tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ extension UTS18Tests {
222222
// - Nonspacing marks are never divided from their base characters, and
223223
// otherwise ignored in locating boundaries.
224224
func testSimpleWordBoundaries() {
225-
let simpleWordRegex = regex(#".+?\b"#).wordBoundaryKind(.unicodeLevel1)
225+
let simpleWordRegex = regex(#".+?\b"#).wordBoundaryKind(.simple)
226226
expectFirstMatch(input, simpleWordRegex, input[pos: ..<11])
227227
expectFirstMatch("don't", simpleWordRegex, "don")
228228
expectFirstMatch("Cafe\u{301}", simpleWordRegex, "Café")

0 commit comments

Comments
 (0)