Module lessons (4/4)
Lookaround in practice
Extract a value without including the context, validate passwords, parse delimited numbers.
What you'll learn in this lesson
- Combine multiple lookaheads anchored to
^to build multi-criteria validators (passwords, identifiers, tokens). - Tile
(?<=...)and(?=...)in the same pattern to extract content exactly between two delimiters without capturing them. - Insert zero-width virtual separators to format digits (thousands separator) or split strings in CamelCase.
Overview
Lookarounds express their maximum potential when combined together: multiple stacked lookaheads test independent conditions on the entire string, while lookbehind + lookahead isolates the text exactly between two markers without including them.
Each lookaround takes up zero characters in cursor advancement. So you can put two or three of them one after the other in the same place (like ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)) to check multiple rules at once, or enclose a token between a rearview mirror and a look forward: (?<=prefix)BODY(?=suffix).
Sections covered in this lesson
- 1Mental model: zero-width parallel sensors
- 24 progressive examples step by step
- 3Guided practical exercises
- 4Quick check
Unlock "Lookaround in practice" and the full Regex Course curriculum
Extract a value without including the context, validate passwords, parse delimited numbers.
Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Regex Course plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.