Patterns
Tune the detector finer: . is any character, \d a digit, \< and \> word edges, \c any case, and \zs puts the cursor on the part of the match you want.
Monday, 2:20 p.m. The rider logs from Friday: twenty-four stops, one per line. Eight of them, every order Friday's override touched, have the latitude and the longitude swapped, and in Miami a latitude is never negative. Searching for 25 beeps at every latitude, good and bad alike.
What you need to say is a latitude that starts with a minus. The detector has finer settings than a word.
Warm-up from earlier chapters
Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.
order, landing on its last letter.order, landing on its last letter.Any coin at all
In a search, a few characters are settings rather than letters. The most common is ., which matches any character: /2.5 finds 2.5, but also 205 and 2x5. When you mean a real dot, put a backslash before it: /2\.5.
Which one beeps first?
You search with /2.5 and ↵. Where does the cursor land?
Kinds of character
Some settings beep for a kind of coin rather than one coin: \d matches any digit and \s any space or tab, so /lat: \d finds a latitude that starts with a digit. \< and \> only beep for whole coins, marking the edges of a word: /\<lat\> finds lat but not latitude, which is exactly what * searches for.
Just a minus?
A swapped stop has a minus in its latitude. You search for just - from the top of the log. Where is the first match?
Stand on the part you want
\zs says the match starts here: everything before it has to be there, but the cursor lands after it. /lat: \zs- finds a latitude that starts with a minus and puts the cursor on the minus. (\ze does the same for the end.)
Find the swaps
Land on the minus of the first four negative latitudes, top to bottom. One pattern with \zs, then n.
This exercise needs a keyboard. Read on, and play it at your computer.
Any case, fewer backslashes
\c anywhere in a pattern tells the detector to ignore case: /\corder finds Order and ORDER too. And \v at the start (very magic) is a simpler dial: it lets parentheses, braces, + and ? work without backslashes: /\v\d+ instead of /\d\+. Handy once patterns get long.
Settings, from memory
Press the keys.
order as a whole word only.order as a whole word only.All eight
Every swapped stop in the rider logs, top to bottom: land on the minus of each negative latitude. This time you start at the end of the file, and the pattern is yours to write. Count them as you go.
Stuck? Show a hint
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.