Regex Tester
Test and debug regular expressions with real-time matching, group capture, and cheat sheet.
What regex syntax does this tool support?
This tool supports JavaScript regular expression syntax, which is widely used in web development. It supports flags like g (global), i (case-insensitive), m (multiline), s (dotAll), and u (unicode).
How do I capture groups in my regex?
Use parentheses () to create capture groups. Matched groups are displayed below the results. For example, (\d+)-(\d+) will capture two number groups separated by a hyphen.
What are regex flags?
Flags modify how the regex engine searches. g = global (find all matches), i = case-insensitive, m = multiline (^ and $ match line boundaries), s = dotAll (. matches newlines), u = unicode mode.
Why is my regex not matching?
Common issues include: missing escape characters for special chars like . * + ?, incorrect anchors, or wrong flag settings. Check the error message displayed below the pattern input for syntax errors.
How do I match special characters?
Escape special characters with a backslash. For example, \. matches a literal dot, \* matches a literal asterisk, and \? matches a literal question mark.
What is the difference between greedy and lazy quantifiers?
Greedy quantifiers (*, +, ?, {}) match as much as possible, while lazy quantifiers (*?, +?, ??, {}?) match as little as possible. For example, <.*> matches the entire string, while <.*?> matches the shortest possible tag.
How do I use character classes?
Character classes [abc] match any single character in the brackets. You can use ranges like [a-z] for lowercase letters, [0-9] for digits, or [^abc] to negate (match anything except a, b, or c).
Can I test multiple patterns at once?
No, this tool tests one pattern at a time. However, you can quickly switch between patterns and test strings to compare results.
Does this tool support lookaheads and lookbehinds?
Yes, JavaScript regex supports positive lookahead (?=), negative lookahead (?!), positive lookbehind (?<=), and negative lookbehind (?<!) assertions.
How do I match unicode characters?
Use the u flag to enable unicode mode. Then you can use \u{XXXX} syntax for unicode code points, or character properties like \p{Letter} to match any letter in any language.
What are anchors in regex?
Anners are zero-width assertions that match positions, not characters. ^ matches the start of a line (or string), $ matches the end, \b matches word boundaries, and \B matches non-word boundaries.
How do I replace matched text?
Switch to the Replace tab and enter your replacement pattern. You can use $1, $2, etc. to reference captured groups. The replacement is applied to all matches when using the g flag.
How to Use Regex Tester
Test regular expressions live against sample text, inspect every match and capture group, and check syntax for multiple languages — all inside your browser.
- Type your pattern into the regex field and paste the sample text you want to match against in the input area below.
- Toggle the flag buttons to change matching behavior: g for global, i to ignore case, m for multiline, s for dotall, u for unicode and y for sticky.
- Switch the language tab — JavaScript, TypeScript, Python, Java, C# or C++ — to see flavor-specific syntax and escaping differences.
- Review the highlighted matches and capture groups listed under your pattern to spot why something matches or fails.
- Open a preset from the dropdown for common recipes like emails, URLs or dates, and adapt it instead of writing from scratch.
A pattern that works in JavaScript may behave differently in Python — always re-test after switching the language tab.
Related Tools
- Text Replacer Free online find and replace tool. Supports plain text and regex patterns with case-sensitive, whole-word, and batch replace options. 100% browser-based, no upload.
- Chmod Calculator Free online chmod calculator to visualize and calculate Linux file permissions with checkboxes. Instantly convert between numeric (755, 644) and symbolic notation (rwxr-xr-x). Supports special permissions like setuid, setgid, sticky bit.
- ASCII Table Complete ASCII character encoding reference with decimal, hexadecimal, octal, binary codes, HTML entities, and character descriptions. Search and filter instantly.
- HTTP Request Tester Test REST APIs directly in your browser. Send GET, POST, PUT, DELETE requests with custom headers, body, and query parameters. View response status, headers, and JSON body instantly.
- .htaccess Generator Generate Apache .htaccess rules for redirects, rewrites, security headers, caching, compression, and more.
- Robots.txt Generator Free online robots.txt generator. Create and customize robots.txt files to control search engine crawling, manage crawler access, and optimize your site's SEO with an easy visual editor.
- Sitemap Generator Free online XML sitemap generator. Add URLs, set priorities, change frequencies and create SEO-friendly sitemaps instantly in your browser.
- Line Sort Sort text lines alphabetically, numerically, or by length. Remove duplicates and reverse order with one click.