Regex Cheat Sheet: Complete Guide for Developers
Regular expressions are one of the highest-leverage skills a developer can own. A well-written regex can replace 50 lines of string-parsing logic. A poorly understood one can silently corrupt data ...

Source: DEV Community
Regular expressions are one of the highest-leverage skills a developer can own. A well-written regex can replace 50 lines of string-parsing logic. A poorly understood one can silently corrupt data or miss edge cases for years. This guide is designed to be the last regex reference you'll need to bookmark. It covers core syntax, every major construct with practical examples, and a library of copy-paste patterns for the most common developer use cases. Use the DevPlaybook Regex Tester to run any pattern as you read. Core Syntax Reference Literal Characters and Escaping Most characters match themselves. The following characters have special meaning and must be escaped with \ when you want the literal character: . * + ? ^ $ { } [ ] | ( ) \ # Match a literal period \. # Match a literal dollar sign \$ # Match a literal parenthesis \( The Dot . matches any single character except a newline (by default). c.t # matches: cat, cot, cut, c3t, c@t # does NOT match: ct, cart In dotall/single-line mod