Regex Tester
Test your regular expressions against sample text.
Test, Debug, and Understand Regular Expressions (Regex) in Real Time
There is a famous quote in computer programming by Jamie Zawinski: "Some people, when confronted with a problem, think 'I know, I'll use regular expressions.' Now they have two problems."
Regular expressions (Regex) are an indispensable tool in software development. They power form validation, text parsing, log scraping, search-and-replace routines, and URL routing. Yet, because of their dense, symbolic syntax, writing a pattern by hand often feels like deciphering hieroglyphics.
A single misplaced quantifier, a forgotten escape slash, or an unanchored group can cause your regex to match strings it should reject, reject valid user inputs, or—in catastrophic cases—trigger a Regular Expression Denial of Service (ReDoS) freeze that locks up your production CPU.
Our free online Regex Tester highlights matches live as you type, breaks down capture groups, explains each token in plain English, and provides a library of pre-tested patterns for emails, phone numbers, and URLs.
The Regex Quick Reference Cheat Sheet
Anchors & Boundaries
- ^ : Start of string or line
- $ : End of string or line
- \b : Word boundary
- \B : Non-word boundary
Character Classes
- \d : Any digit [0-9]
- \D : Any non-digit character
- \w : Word character [a-zA-Z0-9_]
- \s : Whitespace (space, tab, newline)
- . : Any character except newline
Quantifiers (How Many Times)
- * : 0 or more times (greedy)
- + : 1 or more times (greedy)
- ? : 0 or 1 time (optional)
- {n,m} : Between n and m times
- *? / +? : Lazy / non-greedy match
Groups & Lookarounds
- (abc) : Capturing group
- (?:abc) : Non-capturing group
- (?=abc) : Positive lookahead
- (?!abc) : Negative lookahead
Popular Pre-Built Regex Recipes
Warning: Beware of Catastrophic Backtracking (ReDoS)
When you nest greedy quantifiers inside groups—such as `(a+)+$`—a non-matching string like `aaaaaaaaaaaaaaaaaaaaX` causes traditional NFA regex engines to evaluate every possible permutation of groupings.
For a string of just 30 characters, the engine can execute over 1 billion backtracking steps, freezing your Node.js or Python thread at 100% CPU usage. Always avoid nesting unrestricted repetition operators and test edge cases thoroughly before shipping regex to backend API endpoints.
Frequently Asked Questions
What do the 'g', 'i', and 'm' regex flags mean?
`g` (Global) finds all matches in the text rather than stopping after the first match. `i` (Case-Insensitive) matches regardless of uppercase or lowercase letters. `m` (Multiline) changes `^` and `$` to match the start and end of each individual line instead of the entire string.
Does JavaScript regex support lookbehinds?
Yes, modern JavaScript (ECMAScript 2018+) fully supports positive lookbehind `(?<=abc)` and negative lookbehind `(?<!abc)` across all modern browsers and Node.js environments.
Is regex processing safe on this website?
Yes, tests execute safely in a sandboxed Web Worker within your browser session so you can test patterns without risking any server data transmission.