Regular Expressions 5 lessons
  1. 1 The hour that pays for years
  2. 2 The pieces you need sign in to open
  3. 3 Capturing and replacing sign in to open
  4. 4 Writing one that is correct sign in to open
  5. 5 Using it well in real work sign in to open
Course overview
Data: video · change

This lesson: 122KB

Regular Expressions · Lesson 1 of 5

The hour that pays for years

Learn what this tool is and when to use it.

A regular expression is a pattern for matching text. Once you can write one, a class of tasks that used to mean hours of manual editing becomes a few seconds.

What it replaces. Finding every phone number in a document. Extracting all the email addresses from a log. Validating that an input has the right shape. Renaming three hundred files consistently. Replacing a pattern across a whole codebase. Pulling fields out of semi structured text.

Where you will use it. Every editor's find and replace, every programming language, grep on the command line, database queries, log analysis, and form validation. It is one of the few skills that transfers unchanged everywhere.

Why people avoid it. The syntax is dense and unfamiliar, and a complicated expression is genuinely hard to read. Both are true, and the response is to learn the common parts properly rather than the whole of it, because about a dozen constructs cover the overwhelming majority of real use.

Where it is the wrong tool. Parsing HTML, JSON or any nested structure. These are not regular and an expression that appears to work on your examples will fail on valid input you did not test. Use a proper parser.

And the practical warning. A long expression written today is unreadable in a month, including by you. Comment it, or break it into steps, or use a named pattern feature where your language has one.

Lab — try it yourself

Find one task you do by hand that involves finding a pattern in text. That is the task this course is for.

Check what you learned

Create your free BvLogic ID to take the quiz and record your score.

Create your BvLogic ID
Continue to lesson 2 Up next 2. The pieces you need