Regex Tester
Test regular expressions with real-time match highlighting, capture groups, and replace preview. 100% client-side — no data leaves your browser.
Regular Expression
Test String
Match Results
Find & Replace
Use $1, $2, etc. for captured groups. Use $& for the full match.
Regex Cheat Sheet
Character Classes
| . | Any character (except newline) |
| \d | Digit [0-9] |
| \D | 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] | Range: a to z |
Quantifiers
| * | 0 or more |
| + | 1 or more |
| ? | 0 or 1 (optional) |
| {n} | Exactly n times |
| {n,} | n or more times |
| {n,m} | Between n and m times |
| *? | 0 or more (lazy) |
| +? | 1 or more (lazy) |
Anchors & Boundaries
| ^ | Start of string / line |
| $ | End of string / line |
| \b | Word boundary |
| \B | Non-word boundary |
| (?=...) | Positive lookahead |
| (?!...) | Negative lookahead |
| (?<=...) | Positive lookbehind |
| (?<!...) | Negative lookbehind |
Groups & References
| (...) | Capturing group |
| (?:...) | Non-capturing group |
| (?<name>...) | Named capturing group |
| \1 | Backreference to group 1 |
| a|b | Alternation (a or b) |
| $1 | Group 1 in replacement |
| $& | Full match in replacement |
About Regular Expressions
Regular expressions (regex or regexp) are powerful patterns used to match, search, and manipulate text. They are supported by virtually every programming language, text editor, and command-line tool. This free online regex tester lets you build and test patterns in real time with instant visual feedback.
What Are Regular Expressions?
A regular expression is a sequence of characters that defines a search pattern. Regex patterns can match literal text, character classes, repetitions, and complex structures like lookaheads and backreferences. They are essential for tasks like input validation, data extraction, log parsing, search-and-replace, and text processing.
Regex Flags Explained
Flags modify how the regex engine processes a pattern:
g(global) — Find all matches in the string, not just the first one.i(case insensitive) — Match letters regardless of case.m(multiline) —^and$match the start and end of each line, not just the entire string.s(dotall / single line) — The dot.matches newline characters as well.u(unicode) — Enables full Unicode matching, treating surrogate pairs as single characters.
Common Regex Use Cases
- Email validation:
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} - URL matching:
https?:\/\/[^\s/$.?#].[^\s]* - IP address detection:
\b(?:\d{1,3}\.){3}\d{1,3}\b - Date parsing:
\d{4}-\d{2}-\d{2} - HTML tag matching:
<([a-zA-Z]+)\b[^>]*>.*?<\/\1>
Tips for Writing Regex
- Start simple and build up complexity gradually. Test each part before combining.
- Use non-capturing groups
(?:...)when you don't need the captured value. - Prefer lazy quantifiers (
*?,+?) when matching content between delimiters. - Anchor your patterns with
^and$when validating entire strings. - Escape special characters (
. * + ? ^ $ { } [ ] ( ) | \) with a backslash when matching them literally. - Be cautious with
.*— it is greedy by default and may match more than intended.
JavaScript Regex Engine
This tool uses the JavaScript regex engine (RegExp), which supports ECMAScript 2018+ features including named capture groups, lookbehinds, and the s (dotall) flag. The behavior may differ slightly from PCRE (PHP/Python) or POSIX regex engines. All processing happens entirely in your browser — your test data is never sent to any server.