JavaScript Regex Cheatsheet
A complete reference guide for regular expressions with an interactive live tester.
Anchors & Boundaries
Character Classes
Quantifiers
Groups & Lookarounds
JavaScript Flags
Escape Sequences
Common Regular Expression Patterns
^[^\s@]+@[^\s@]+\.[^\s@]+$Example match: user@example.com
https?:\/\/[\w\-._~:/?#[\]@!$&'()*+,;=%]+Example match: https://example.com
\b(?:\d{1,3}\.){3}\d{1,3}\bExample match: 192.168.1.1
^\d{4}-\d{2}-\d{2}$Example match: 2026-06-06
^#?(?:[0-9a-fA-F]{3}){1,2}$Example match: #FF6B35 or #f60
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$Example match: Password1
^[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$Example match: 550e8400-e29b-41d4-a716-446655440000
^\s+|\s+$Use with .replace() to trim spaces
About JavaScript Regular Expressions
Mastering pattern matching for data validation, parsing, and text search operations.
Regular expressions (Regex) provide a powerful and concise syntax for matching patterns in strings. In JavaScript, regex objects can be created using literal notation /pattern/flags or the RegExp constructor for runtime pattern construction.
Pattern Validation
Validate form inputs, phone numbers, emails, and postal codes efficiently before submitting data.
String Parsing & Extraction
Extract specific tokens, URLs, parameters, and structured data blocks from complex text logs.
100% Client-Side Testing
Test patterns instantly in your browser sandbox without sending string data across the network.
Instant Feedback
Matches highlight immediately as you edit expressions or update test strings in the sandbox.
Quick Lookup Cards
Easily reference character classes, anchors, and quantifiers right when you need them.
Common Templates
Jumpstart development with pre-tested patterns for emails, URLs, and numeric identifiers.