Skip to content

Commit 8da68d3

Browse files
committed
Updated extended delimiter section
1 parent b41edbd commit 8da68d3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Documentation/Evolution/DelimiterSyntax.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ This allows the captures to be referenced as `match.identifier` and `match.hex`
8888

8989
### Extended delimiters `#/.../#`, `##/.../##`
9090

91-
A regex literal may be surrounded by an arbitrary number of balanced pound characters. This is a somewhat similar to the raw string literal syntax introduced by [SE-0200], and allows a regex literal to use forward slashes without the need to escape them, e.g:
91+
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 pound characters. This changes the delimiter of the literal, and therefore allows the use of forward slashes without escaping. For example:
9292

9393
```swift
9494
let regex = #/usr/lib/modules/([^/]+)/vmlinuz/#
9595
// regex: Regex<(Substring, Substring)>
9696
```
9797

98-
Additionally, it allows for a multi-line mode when the opening delimiter is followed by a new line.
98+
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. The escaping rules for backslashes do not change, and a multi-line mode is entered when the opening delimiter is followed by a newline.
9999

100100
#### Escaping of backslashes
101101

0 commit comments

Comments
 (0)