Video Coming Soon...

Created by Zed A. Shaw Updated 2026-09-11 06:57:01
 

04: Basic Repetition

You are now about to learn the operators that make regex shine. These operators tell grep to repeatedly match characters in a pattern. It's how you make grep find lines with long repetition or big gaps in the line. When you combine these with the operators you've learned so far you can do about 80-90% of what you need from a regex.

We Need a Better Poem

Let's change the poem to a new one just for practice. Create a text file named ex04.txt and put it in your Documents folder just like you did with ex02.txt. Refer back to Exercise 02 if you forgot how to do that.

Here's the new poem:

I led you astray with promises
once burnished and unspoken
yet without you here I apprehend
  unyielding vigilance
for everything I may have broken.

Be sure to get those two space characters at the start of line 4. They totally make the poem.

Previous Lesson Next Lesson

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.