Skip to content

Commit b7913e2

Browse files
[SE-0351] Update links, example code, etc. (#1623)
1 parent 75603c2 commit b7913e2

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

proposals/0351-regex-builder.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Proposal: [SE-0351](0351-regex-builder.md)
44
* Authors: [Richard Wei](https://github.com/rxwei), [Michael Ilseman](https://github.com/milseman), [Nate Cook](https://github.com/natecook1000)
55
* Review Manager: [Ben Cohen](https://github.com/airspeedswift)
6-
* Implementation: [apple/swift-experimental-string-processing](https://github.com/apple/swift-experimental-string-processing/tree/main/Sources/_StringProcessing/RegexDSL)
6+
* Implementation: [apple/swift-experimental-string-processing](https://github.com/apple/swift-experimental-string-processing/tree/main/Sources/RegexBuilder)
77
* Available in nightly toolchain snapshots with `import _StringProcessing`
88
* Status: **Active Review (4 - 18 April 2022)**
99

@@ -55,7 +55,7 @@ let emailPattern = Regex {
5555
let email = "My email is [email protected]."
5656
if let match = email.firstMatch(of: emailPattern) {
5757
let (wholeMatch, name, domain) = match.output
58-
// wholeMatch: "My email is [email protected]."
58+
// wholeMatch: "[email protected]"
5959
// name: "my.name"
6060
// domain: "mail.swift.org"
6161
}
@@ -332,7 +332,7 @@ public enum RegexComponentBuilder {
332332
}
333333
```
334334

335-
When it comes to concatenation, `RegexComponentBuilder` utilizes the [recently proposed `buildPartialBlock` feature](https://forums.swift.org/t/pitch-buildpartialblock-for-result-builders/55561/1) to be able to concatenate all components' capture types to a single result tuple. `buildPartialBlock(first:)` provides support for creating a regex from a single component, and `buildPartialBlock(accumulated:next:)` support for creating a regex from multiple results.
335+
When it comes to concatenation, `RegexComponentBuilder` utilizes the [recently proposed `buildPartialBlock` feature](0348-buildpartialblock.md) to be able to concatenate all components' capture types to a single result tuple. `buildPartialBlock(first:)` provides support for creating a regex from a single component, and `buildPartialBlock(accumulated:next:)` support for creating a regex from multiple results.
336336

337337
Before Swift supports variadic generics, `buildPartialBlock(first:)` and `buildPartialBlock(accumulated:next:)` must be overloaded to support concatenating regexes of supported capture quantities (arities).
338338
- `buildPartialBlock(first:)` is overloaded `arity` times such that a unary block with a component of any supported capture arity will produce a regex with capture type `Substring` followed by the component's capture types. The base overload, `buildPartialBlock<R>(first:) -> Regex<Substring>`, must be marked with `@_disfavoredOverload` to prevent it from shadowing other overloads.
@@ -564,8 +564,6 @@ extension AlternationBuilder {
564564

565565
### Quantification
566566

567-
Quantifiers are free functions that take a regex or a `@RegexComponentBuilder` closure that produces a regex. The result is a regex whose `Output` type is the same as the argument's, when the lower bound of quantification is greater than `0`; otherwise, it is an `Optional` thereof.
568-
569567
Quantifiers are generic types that can be created from a regex component. Their `Output` type is inferred from initializers. Each of these types corresponds to a quantifier in the textual regex.
570568

571569
| Quantifier in regex builder | Quantifier in textual regex |

0 commit comments

Comments
 (0)