Video Coming Soon...

Created by Zed A. Shaw Updated 2026-09-08 23:25:25
 

02: Basic Matching

In this exercise you'll create a simple little text file and use grep (ugrep on Windows) to search for lines in the file. I'll also walk through exactly how a regex work, but keep in mind you'll have to play with them for a while before they really make sense. Just keep experimenting and testing your ideas and you'll get it.

The Setup

To do this exercise you'll need to create a little text file with some text to search. Let's use a little poem:

I have one million bees
None of these have knees
But if I squint
They won't sprint
Even if I also say please

Thank you. Thank you. I'll be off in my studio writing my Nobel Prize acceptance speech now.

Save this file in your Documents folder so you can access it easily and name it ex02.txt.

You'll need to create this text file with a simple text editor like Geany but not with a word processor like Microsoft Word. I repeat, do not use Microsoft Word.

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.