Skip to content

Commit 0d8489f

Browse files
author
Iggy1
committed
fix mixed use of the magic syntax on ch 12
1 parent b837c5a commit 0d8489f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

ch12_search_and_substitute.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,21 @@ When sees the first `"`, it begins the pattern capture. The moment Vim sees the
190190
## Capturing a Phone Number
191191

192192
If you want to match a US phone number separated by a hyphen (`-`), like `123-456-7890`, you can use:
193+
123-456-7890
193194
```
194-
/\v\d\{3\}-\d\{3\}-\d\{4\}
195+
/\d\{3\}-\d\{3\}-\d\{4\}
195196
```
196197

197198
US Phone number consists of a set of three digit number, followed by another three digits, and finally by four digits. Let's break it down:
198199
- `\d\{3\}` matches a digit repeated exactly three times
199200
- `-` is a literal hyphen
200201

202+
You can avoid typing escapes with `\v`:
203+
204+
```
205+
/\v\d{3}-\d{3}-\d{4}
206+
```
207+
201208
This pattern is also useful to capture any repeating digits, such as IP addresses and zip codes.
202209

203210
That covers the search part of this chapter. Now let's move to substitution.

0 commit comments

Comments
 (0)