Back to articles
Regex Cheat Sheet: The Only Regex Reference You'll Need in 2026

Regex Cheat Sheet: The Only Regex Reference You'll Need in 2026

via Dev.to Webdev楊東霖

Regex Cheat Sheet: The Only Regex Reference You'll Need in 2026 Character Classes Pattern Matches . Any character except newline \d Any digit [0-9] \D Any non-digit \w Word character [a-zA-Z0-9_] \W Non-word character \s Whitespace (space, tab, newline) \S Non-whitespace [abc] Any of a, b, or c [^abc] Not a, b, or c [a-z] Any lowercase letter Quantifiers Pattern Meaning * 0 or more + 1 or more ? 0 or 1 (optional) {n} Exactly n {n,} n or more {n,m} Between n and m *? / +? Lazy (minimum) match Anchors Pattern Meaning ^ Start of string (or line with m flag) $ End of string (or line with m flag) \b Word boundary \B Non-word boundary Common JavaScript Patterns // Email /^ [ ^ \ s @] + @[ ^ \ s @] + \ .[ ^ \ s @] + $ / // URL /https ? : \/\/[^\s] +$/ // Phone (US) /^ \ + ? 1 ?[ - . \ s ]? \ (? \ d { 3 } \ )?[ - . \ s ]? \ d { 3 }[ - . \ s ]? \ d { 4 } $ / // IPv4 /^ (?:(?: 25 [ 0-5 ] |2 [ 0-4 ]\d | [ 01 ]?\d\d?)\.){3}(?: 25 [ 0-5 ] |2 [ 0-4 ]\d | [ 01 ]?\d\d?) $/ // Date YYYY-MM-DD /^ \ d {

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
2 views

Related Articles