Regular Expressions
Regular expressions are pattern-matching sequences used to search, extract, validate, and transform text. This reference covers regex from fundamentals to advanced techniques, with emphasis on practical infrastructure applications.
Why Regex Matters
Regex appears in virtually every technical domain:
| Domain | Applications |
|---|---|
Log Analysis |
Extract timestamps, IPs, error codes, usernames from logs |
Configuration Management |
Validate syntax, find misconfiguration, audit settings |
Security |
IOC extraction, threat hunting, SIEM queries, compliance audits |
Network Engineering |
Parse configs, extract IPs/MACs/VLANs, validate addressing |
Automation |
Data extraction in scripts, API response parsing, file processing |
Development |
Input validation, search/replace, code refactoring |
Data Processing |
ETL pipelines, data cleaning, format conversion |
Curriculum
| Module | Description | Status |
|---|---|---|
Literal characters, metacharacters, escaping, basic matching |
Core |
|
Sets, ranges, negation, shorthand classes (\d, \w, \s) |
Core |
|
Repetition operators, greedy vs lazy matching, possessive quantifiers |
Core |
|
Position matching, word boundaries, line/string anchors |
Core |
|
Capturing groups, backreferences, non-capturing groups, named groups |
Intermediate |
|
OR logic, conditional patterns, branch reset |
Intermediate |
|
Zero-width assertions, positive/negative lookaround |
Advanced |
|
BRE, ERE, PCRE, JavaScript, Python, Vim differences |
Reference |
|
Production-ready patterns for IPs, MACs, logs, configs |
Reference |
|
grep, sed, awk, ripgrep, Python, JavaScript usage |
Reference |
Quick Reference
Essential Metacharacters
| Character | Meaning | Example |
|---|---|---|
|
Any character except newline |
|
|
Escape metacharacter |
|
|
Start of line |
|
|
End of line |
|
|
Alternation (OR) |
|
|
Grouping |
|
|
Character class |
|
Quantifiers Summary
| Greedy | Lazy | Meaning |
|---|---|---|
|
|
Zero or more |
|
|
One or more |
|
|
Zero or one |
|
|
Exactly n |
|
|
n or more |
|
|
Between n and m |
Shorthand Classes
| Shorthand | Equivalent | Meaning |
|---|---|---|
|
|
Digit |
|
|
Non-digit |
|
|
Word character |
|
|
Non-word character |
|
|
Whitespace |
|
|
Non-whitespace |
Learning Path
Week 1: Foundations
-
Complete Fundamentals
-
Complete Character Classes
-
Practice with grep on log files
Week 2: Core Patterns
-
Master Quantifiers
-
Learn Anchors
-
Build first infrastructure patterns
Week 3: Intermediate
-
Study Groups & Capturing
-
Apply Alternation
-
Practice extraction scripts
Week 4: Advanced
-
Master Lookaround
-
Study Flavor Differences
-
Build pattern library
Related Resources
-
Training Sessions - Hands-on practice
-
Regex Mastery Objective - Goal tracking
-
CLI Mastery - Tool integration