Video Coming Soon...
03: Anchoring
In this exercise you'll learn about the concept of "anchoring", which refines a regex to work only on the beginning, end, or entire line of text. I'll also talk about memorizing the main characters in regex to speed up your learning. You'll continue to use the ex02.txt poem from the previous exercise.
Memorizing Regex Operators
The special characters in regex are normally called "operators". I'll use this word when it's one of the special characters like . and use "character" for everything else. Here's some examples:
.-- operatora-- charactera.a.bcharacter operator character operator
To get good at regex you can sit there with a text file and grep until it sinks in organically, or you can help yourself by doing a bit of memorization. If you memorize the few regex operators you'll have an easier time reading and writing regex.
The easiest way to memorize the operators is to create some flash cards. I like using index cards with the operator on one side and the name/description on the other.
Take some time now to make some flash cards like this with the ., \s, \n, \t operators on them. Then spend some time studying them. It doesn't take a long time each day. Maybe 10-20 minutes before you do an exercise.
NOTE A word about Anki: Anki is fine but don't use a flash card set that someone else made. You actually get more value out of cards you make yourself.
Register for Learn Regex the Hard Way
Register to gain access to additional videos which demonstrate each exercise. Videos are priced to cover the cost of hosting.