Regex Lookahead
A regex syntax using (?=...) and (?!...) to match based on what follows without consuming characters.
A regex lookahead is a syntax that checks whether a specific pattern follows the current position without consuming characters. Positive lookahead (?=...) matches when the pattern follows, while negative lookahead (?!...) matches when it does not.
Lookaheads are zero-width assertions, meaning they check conditions without advancing the match position. For example, d+(?=px) matches "100" in "100px" but does not include "px" in the result. Regular expressions introduction books cover lookahead fundamentals.
In password validation, multiple lookaheads can be combined to simultaneously check conditions like "contains a letter," "contains a digit," and "at least 8 characters."
JavaScript also supports lookbehind assertions (?<=...) and (?<!...) since ES2018. Practical regex guides teach advanced pattern techniques.