Regular expressions pcre2 cheatsheet
Regular expressions pcre2: Lookahead and lookbehind
5 common Regular expressions pcre2 tasks.
Match only if followed by something
Match a number only when it is followed by px, without including px in the match.
\d+(?=px)
Match only if preceded by something
Match the digits after a dollar sign, without including the sign.
(?<=\$)\d+
Match only if not preceded by something
Match a number that does not come right after a dollar sign.
(?<!\$)\b\d+\b
Require several conditions at once
Use lookaheads at the start to require a lowercase letter, an uppercase letter, a digit and 8 or more characters.
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$