Linux, terminal and Git

Stage 3 · Lesson 5 of 8

Regular expressions basics

Text tools

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

Practise

  • Test regular expressions on sample text with a plain explanation of each part

  • Middle levels need grep, sort, uniq and find to locate the next password

Keep handy

  • The official jq manual with examples for every filter

  • Quick examples for find, sed, awk and friends when you forget the syntax

Mark this stage as not done?