Stage 3 · Lesson 5 of 8
Regular expressions basics
A , or regex, is a small pattern that describes text. The core pieces are few. . matches any single character.
* means "zero or more of the previous thing" and + means "one or more". ? makes something optional. ^ means the start of a line and $ the end.
[0-9] matches one character from a set, here any digit, and parentheses group parts together. , , , code editors and most programming languages all use regex, with small differences between the basic and extended styles. Build and test patterns on the website with real sample lines before using them on files.
Common trapa pattern that matches too much, such as .* swallowing half a line, so always test on examples that should not match as well.
A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it
Resources for this stage
Start with· follow one of these
- CourseFreeThe Missing Semester of Your CS Education
MIT · Beginner
The data wrangling lecture walks through grep, sed, awk and regular expressions on real logs
- BookFreeThe Linux Command Line
William Shotts · Beginner
Clear chapters on text processing, regular expressions and searching for files