Skip to content

Commit c82ff67

Browse files
Add more escape special character examples
1 parent d811399 commit c82ff67

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

doc/GUIDE.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@ Also, `\z` is more efficient, so it is better to use it in places where `\n` can
186186
Many characters have special meaning in regex (for example `.`, `+`, `*`, `?`, `[`, `(`).
187187
If you mean to match them literally, escape them:
188188

189-
```regex
190-
# Correct: dot is treated literally
191-
example\.com
192-
193-
# Incorrect: dot matches any character
194-
example.com. # also matches "exampleXcom"
195-
```
196-
189+
| Literal You Want | Correct Regex | Explanation |
190+
|----------------------------|-----------------------------|--------------------------------------------|
191+
| `example.com` | `example\.com` | `.` matches any character unless escaped |
192+
| `a+b` | `a\+b` | `+` means “one or more” |
193+
| `price?` | `price\?` | `?` means “optional” |
194+
| `[value]` | `\[value\]` | `[` and `]` start/end a character class |
195+
| `(test)` | `\(test\)` | `(` and `)` begin/end a group |
196+
| Markdown link `[t](u)` | `(\[[^]]*\]\([^)]*\))` | Matches `[text](url)` without crossing `]` or `)` |
197197
---
198198

199199
### 5. Use Non-Capturing Groups

0 commit comments

Comments
 (0)