Embed this tool on your site
<iframe src="https://devtoolbox.dedyn.io/tools/regex-cheatsheet" width="100%" height="700" frameborder="0" title="Regex Cheat Sheet & Quick Reference"></iframe>

Regex Cheat Sheet & Quick Reference

Interactive regex reference with searchable syntax table, live pattern tester, and 25+ common patterns ready to copy. Click any row to test it instantly.

Quick Pattern Tester

Enter a regex pattern above to see matches highlighted here...

Regex Syntax Reference

Click any row to load it into the pattern tester above.

Pattern Description Example Matches

Common Regex Patterns

25+ pre-built patterns for everyday tasks. Click to test, or copy directly to your project.

About This Regex Cheat Sheet

Regular expressions (regex) are powerful pattern-matching tools used in every major programming language. This interactive cheat sheet covers the complete regex syntax with searchable reference, live testing, and ready-to-use patterns.

Whether you are validating user input, parsing log files, or performing find-and-replace operations, this reference has the syntax and examples you need. All testing runs entirely in your browser using JavaScript's built-in RegExp engine.

Features

Frequently Asked Questions

What is a regular expression (regex)?
A regular expression (regex) is a sequence of characters that defines a search pattern. It is used for string matching, validation, search-and-replace, and text parsing in virtually every programming language. Common uses include validating email addresses, extracting data from logs, and finding patterns in text.
What is the difference between greedy and lazy quantifiers?
Greedy quantifiers (*, +, {n,m}) match as many characters as possible, while lazy quantifiers (*?, +?, {n,m}?) match as few characters as possible. For example, given the string '<b>bold</b>', the greedy pattern '<.*>' matches the entire string, while the lazy pattern '<.*?>' matches only '<b>'. Use lazy quantifiers when you want the shortest possible match.
How do lookaheads and lookbehinds work in regex?
Lookaheads and lookbehinds are zero-width assertions that match a position without consuming characters. A positive lookahead (?=...) asserts that what follows matches the pattern. A negative lookahead (?!...) asserts that what follows does NOT match. Lookbehinds work the same way but check what comes before: (?<=...) for positive and (?<!...) for negative. For example, '\d+(?= dollars)' matches digits only when followed by ' dollars'.
Keyboard Shortcuts
Ctrl+Enter Run / Test
Ctrl+Shift+C Copy output
Ctrl+L Clear