Regex Tester
Test JavaScript regular expressions live with instant match highlighting. Supports all JS regex flags (g, i, m, s, u) and shows match groups, indices, and global matches.
2 match(es)
- @12: alice@example.comGroups: $1=alice, $2=example.com
- @33: bob@example.orgGroups: $1=bob, $2=example.org
How to use the regex tester
Enter a regular expression and flags, then test against any input. Each match shows its index and capture groups.
Formula & explanation
JavaScript regex syntax (PCRE-like, but not identical). Common flags: g (global), i (case-insensitive), m (multi-line), s (dotall).
Examples
Pattern: \d{3}-\d{4} matches "555-1234". Pattern with capture: (\w+)@(\w+\.\w+) extracts user and domain.
Frequently asked questions
- What flags can I use?
- JavaScript supports g (global — find all matches), i (case-insensitive), m (multiline — ^ and $ match line boundaries), s (dotall — dot matches newlines), and u (Unicode mode).
- Why does my regex match nothing?
- Common causes: forgetting to escape special characters like . + * ? ( ) [ ] { } ^ $ | \ — prepend a backslash to match them literally.
- How do I extract a specific part of a match?
- Wrap the part you want in parentheses to create a capture group. The tool displays each group's value alongside the full match.
- Is JavaScript regex the same as PCRE?
- Mostly, but not identical. JavaScript lacks some PCRE features (lookbehind support improved in ES2018, no possessive quantifiers or atomic groups). Code tested here may need small adjustments for Python/PHP/Perl.
Related developer tools tools
- JS MinifierMinify JavaScript using Terser — removes whitespace, shortens variable names, and removes dead code. Paste your JS and get a production-ready compressed bundle.
- Cron Expression Parser — Explain & Preview RunsExplain any cron expression in plain English and preview the next run times. Supports 5-field crontab, 6-field, and @hourly/@daily/@weekly shortcuts. Free, no signup.
- Curl to Code ConverterPaste a curl command, get equivalent code in JavaScript (fetch/axios), Python (requests), or Go (net/http). Handles headers, JSON bodies, basic auth, and form data.
- String Escape/UnescapeEscape and unescape strings for JSON, JavaScript, HTML, and SQL. Handles special characters, backslashes, quotes, newlines, and Unicode escape sequences instantly.
- HTML EditorWrite HTML with live preview side-by-side. Syntax-highlighted editor with formatted source view — useful for testing snippets, email templates, or quick mockups in your browser.
- JSON FormatterPretty-print, minify, and validate JSON. Detects syntax errors with line numbers and supports nested structures of any depth.