fix mixed use of the magic syntax on ch 12

pull/37/head
Iggy1 4 years ago
parent b837c5a6e6
commit 0d8489f2a1

@ -190,14 +190,21 @@ When sees the first `"`, it begins the pattern capture. The moment Vim sees the
## Capturing a Phone Number
If you want to match a US phone number separated by a hyphen (`-`), like `123-456-7890`, you can use:
123-456-7890
```
/\v\d\{3\}-\d\{3\}-\d\{4\}
/\d\{3\}-\d\{3\}-\d\{4\}
```
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:
- `\d\{3\}` matches a digit repeated exactly three times
- `-` is a literal hyphen
You can avoid typing escapes with `\v`:
```
/\v\d{3}-\d{3}-\d{4}
```
This pattern is also useful to capture any repeating digits, such as IP addresses and zip codes.
That covers the search part of this chapter. Now let's move to substitution.

Loading…
Cancel
Save