Regex: Actually Useful Patterns
Master regular expressions from syntax basics to real-world extraction, validation, and transformation tasks. You build a log parser, form validator, and data scrubber by the end.
Course Content
6 modules · 30 lessonsRegex Fundamentals
Students can read, write, and test basic regex patterns using literals, metacharacters, and quantifiers.
What is a regex and how does it actually work
pattern matching, regex engine, literal characters, match vs search, test method, basic syntax
Regex metacharacters dot star plus question mark explained
dot wildcard, star quantifier, plus quantifier, question mark quantifier, greedy matching, literal escaping
Character classes and ranges in regex
character class syntax, ranges, negated classes, shorthand classes \d \w \s, combining shorthands
Anchors caret and dollar sign in regex
start anchor, end anchor, whole-string matching, multiline flag, word boundary \b, anchor use cases
Regex flags global case-insensitive multiline explained
g flag, i flag, m flag, s flag, flag combinations, findAll behavior, flag syntax JS vs Python
Groups and Capturing
Students can extract specific parts of a match using capturing groups, named groups, and non-capturing groups.
How capturing groups work in regex
capturing group syntax, group index, match array, nested groups, group numbering order
Named capture groups in regex for readable patterns
named group syntax, groups.name access, named backreferences, Python named groups, readability benefits
Non-capturing groups and grouping without capturing
non-capturing group syntax, performance difference, grouping for quantifiers, alternation scope, when to use
Backreferences in regex to match repeated text
backreference syntax \1, named backreference \k, duplicate detection, HTML tag matching, backreference limitations
How to extract all matches with regex in JavaScript and Python
matchAll, findall, iterator protocol, destructuring group results, global flag requirement, match vs matchAll
Lookaheads and Lookbehinds
Students can write zero-width assertions to match patterns only when preceded or followed by specific context, without including that context in the match.
Positive lookahead in regex how it works
positive lookahead syntax, zero-width assertion, match vs consume, practical use cases, password validation example
Negative lookahead in regex to exclude patterns
negative lookahead syntax, exclusion patterns, matching words not followed by something, practical filtering examples
Lookbehind assertions in regex positive and negative
positive lookbehind syntax, negative lookbehind syntax, browser support, extracting currency amounts, lookbehind limitations variable length
Combining lookaheads and lookbehinds for complex conditions
chaining assertions, extract between delimiters, password strength pattern, assertion order, real-world extraction examples
When not to use lookaheads and regex alternatives
performance cost of lookaheads, catastrophic backtracking risk, readability tradeoffs, when to use string methods instead, nested quantifier danger
Quantifiers and Greedy vs Lazy Matching
Students can control how much text a quantifier consumes by switching between greedy and lazy modes, preventing over-matching bugs.
Greedy quantifiers and why they over-match
greedy default behavior, star plus greedy, over-matching HTML, match expansion, how greedy backtrack works
Lazy quantifiers in regex with question mark suffix
lazy quantifier syntax, star question, plus question, lazy vs greedy comparison, HTML tag matching fix
Negated character class vs lazy quantifier which to use
negated class as delimiter stopper, performance comparison, correctness differences, nested delimiter problem, practical choice guide
Exact and range quantifiers in regex
exact quantifier, minimum quantifier, range quantifier, phone number pattern, input length validation, combining with anchors
Possessive quantifiers and atomic groups to prevent backtracking
possessive quantifier syntax, atomic group, backtracking prevention, performance use cases, Java vs JavaScript support
Real-World Validation Patterns
Students can write production-quality regex patterns for email, URL, phone number, and credit card validation with known edge cases handled.
Email validation with regex what actually works
RFC 5321 overview, practical email regex, local part rules, domain rules, TLD length, common false positives, validation tradeoffs
URL validation and parsing with regex
URL components, protocol matching, optional www, path and query string, fragment, named groups for parsing, URL constructor alternative
Phone number validation regex for multiple formats
US phone formats, international format, optional parts, character class for separators, normalization after match, test suite approach
Credit card number regex validation and formatting
card number structure, Luhn algorithm role, format validation vs Luhn check, card type detection, grouping pattern, security note
Building a reusable regex validation library in JavaScript
module pattern, compiled regex constants, validate function, error messages, chaining validators, TypeScript types optional
Regex for Data Extraction and Transformation
Students can use regex to parse log files, extract structured data from unstructured text, and perform complex find-and-replace transformations.
Parsing structured log files with regex
log format anatomy, named groups for log parsing, multiline processing, error level extraction, timestamp normalization, performance on large files
Extracting emails phone numbers and URLs from unstructured text
extract vs validate distinction, word boundary use, overlapping matches, deduplication, running multiple patterns over same text
Find and replace with regex using dynamic patterns
replace with function callback, dynamic replacement, conditional replace, casing transforms, template substitution
Regex to parse CSV and TSV data rows
CSV edge cases, quoted fields with commas, newlines in quoted fields, split vs regex, RFC 4180, Python csv module note
Building a regex-powered search and highlight function
dynamic regex from user input, escaping user input, highlight with replace, case-insensitive search, performance with large DOM, XSS prevention
