You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Standardize on "number signs" for mentions of `#`
(though a couple of them read better as just the
character). Also change the multi-line example to
not include a `/` at the start, which matches the
single-line version.
Copy file name to clipboardExpand all lines: Documentation/Evolution/DelimiterSyntax.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -87,18 +87,18 @@ This allows the captures to be referenced as `match.identifier` and `match.hex`,
87
87
88
88
### Extended delimiters `#/.../#`, `##/.../##`
89
89
90
-
Backslashes may be used to write forward slashes within the regex literal, e.g `/foo\/bar/`. However, this can be quite syntactically noisy and confusing. To avoid this, a regex literal may be surrounded by an arbitrary number of balanced octothorpes. This changes the delimiter of the literal, and therefore allows the use of forward slashes without escaping. For example:
90
+
Backslashes may be used to write forward slashes within the regex literal, e.g `/foo\/bar/`. However, this can be quite syntactically noisy and confusing. To avoid this, a regex literal may be surrounded by an arbitrary number of balanced number signs. This changes the delimiter of the literal, and therefore allows the use of forward slashes without escaping. For example:
91
91
92
92
```swift
93
93
let regex =#/usr/lib/modules/([^/]+)/vmlinuz/#
94
94
// regex: Regex<(Substring, Substring)>
95
95
```
96
96
97
-
The number of pounds may be further increased to allow the use of e.g `/#` within the literal. This is similar in style to the raw string literal syntax introduced by [SE-0200], however it has a couple of key differences. Backslashes do not become literal characters. Additionally, a multi-line mode, where whitespace and line-ending comments are ignored, is entered when the opening delimiter is followed by a newline.
97
+
The number of `#` characters may be further increased to allow the use of e.g `/#` within the literal. This is similar in style to the raw string literal syntax introduced by [SE-0200], however it has a couple of key differences. Backslashes do not become literal characters. Additionally, a multi-line mode, where whitespace and line-ending comments are ignored, is entered when the opening delimiter is followed by a newline.
98
98
99
99
```swift
100
100
let regex =#/
101
-
/usr/lib/modules/ # Prefix
101
+
usr/lib/modules/ # Prefix
102
102
(?<subpath>[^/]+)
103
103
/vmlinuz # The kernel
104
104
#/
@@ -143,7 +143,7 @@ let regex = #/
143
143
144
144
In this mode, [extended regex syntax][extended-regex-syntax]`(?x)` is enabled by default. This means that whitespace becomes non-semantic, and end-of-line comments are supported with `# comment` syntax.
145
145
146
-
This mode is supported with any (non-zero) number of pound characters in the delimiter. Similar to multi-line strings introduced by [SE-0168], the closing delimiter must appear on a new line. To avoid parsing confusion, such a literal will not be parsed if a closing delimiter is not present. This avoids inadvertently treating the rest of the file as regex if you only type the opening.
146
+
This mode is supported with any (non-zero) number of `#` characters in the delimiter. Similar to multi-line strings introduced by [SE-0168], the closing delimiter must appear on a new line. To avoid parsing confusion, such a literal will not be parsed if a closing delimiter is not present. This avoids inadvertently treating the rest of the file as regex if you only type the opening.
0 commit comments