Regex Tester Online: Test JavaScript Regular Expressions
Regex tester online: test JavaScript regular expressions with live matches, group capture, and syntax error highlighting.
Updated 2026-08-16
Related Tools
Base64 Encoder/Decoder: Encode & Decode Text Online
URL Encoder/Decoder: Percent Encoding & Decoding Online
JSON Formatter: Beautify, Validate & Minify JSON Online
JWT Decoder Online: Decode & Debug JSON Web Tokens
Hash Calculator: MD5, SHA-256 & 25+ Algorithms Online
Code Beautifier: Format HTML, CSS & JavaScript Online
Features
- Real-time match highlighting: see matches light up instantly as you type your pattern or test string
- Capture groups visualization: all numbered and named groups displayed with their matched content in a structured table
- Detailed match information for each match including exact position (index), length, and full match text
- Regex flag toggles: switch between global (g), case-insensitive (i), multiline (m), dotAll (s), and Unicode (u) modes with one click
- Replacement testing mode: test your replace patterns with $1, $2 back-references and see the result in real time
- Common regex library: one-click load pre-built patterns for email, URL, phone number, IP address, date, password validation, and more
- Syntax error detection with clear, human-readable error messages when your regex is invalid
- Match count statistics: total matches found, total capture groups, and processing time displayed in the status bar
- One-click copy pattern or matches to clipboard for quick sharing with teammates
- Full JavaScript RegExp engine compatibility: uses the browser's native engine so results are identical to your production code
- Works offline after first load
How to Use
- 1Enter your regular expression pattern in the "Pattern" field at the top. Use forward slashes (/pattern/) or enter the raw pattern without delimiters.
- 2Toggle the flags below the pattern field: g (global: find all matches), i (case-insensitive), m (multiline: ^$ match line boundaries), s (dotAll: dot matches newlines), u (Unicode: full Unicode support).
- 3Paste or type your test string in the input area below. Matches highlight automatically as you type.
- 4View detailed match information in the right panel: each match shows its position, length, captured groups, and the full matched text.
- 5Switch to Replace mode to test substitution patterns. Enter your replacement string with $1, $2 references to use capture groups.
- 6Click any preset pattern from the Common Patterns library to quickly load frequently-used regexes like email validation or URL matching.
- 7Copy the pattern or results using the toolbar buttons. Download matches as a text file if needed.
- 8Use the Regex Explanation panel to break down complex patterns; each token is explained in plain English to help you understand what your regex does.
Frequently Asked Questions
What is a regular expression (regex)?
A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. It's used for finding, replacing, validating, and extracting text based on pattern rules. For example, `\d{3}-\d{4}` matches phone number patterns like "555-1234". Regex is supported in almost every programming language (JavaScript, Python, Java, PHP, Go, Rust) and text editor (VS Code, Sublime Text). This tool uses JavaScript's native RegExp engine, so results match exactly what your JS code produces. (See: MDN RegExp documentation)
What do the regex flags mean?
Flags modify how the regex engine behaves:
• **g (Global)**: Find all matches instead of stopping after the first one
• **i (Case-insensitive)**: Match uppercase and lowercase letters interchangeably: /hello/i matches "Hello", "HELLO", "hello"
• **m (Multiline)**: Make ^ and $ match the start/end of each line instead of the entire string
• **s (dotAll / Single-line)**: Make . (dot) match newline characters too, not just non-newline characters
• **u (Unicode)**: Enable full Unicode support including emoji, CJK characters, and Unicode property escapes like \p{Script=Han}. (See: MDN RegExp documentation)
How do capture groups work?
Capture groups are parts of your regex enclosed in parentheses (...) that extract specific portions of each match. For example, `(\d{3})-(\d{4})` in "555-1234" creates two groups: Group 1 = "555", Group 2 = "1234". You can name groups with `(?<name>...)` syntax for easier reference: `(?<area>\d{3})-(?<number>\d{4})`. In replacement strings, refer to groups as $1, $2 (numbered) or $<name> (named). Non-capturing groups `(?:...)` group without capturing; use them when you need grouping logic but don't need the extracted value.
Why does my regex show as invalid?
Common causes of invalid regex: unescaped special characters (use \\ for literal backslash, \. for literal dot), mismatched parentheses (every opening ( needs a closing)), invalid quantifier placement (cannot put + after a group that doesn't exist), or unsupported syntax in JavaScript (lookbehinds require fixed width, recursive patterns aren't supported). The error message shows exactly where the parser failed; look for the red error indicator near the problematic character. Tip: start simple, add complexity gradually, and test after each change.
Does this support PCRE or Python regex?
This tool uses JavaScript's native RegExp engine (ECMAScript standard). It covers most common regex syntax shared across languages: character classes (\d, \w, \s), quantifiers (*, +, ?, {n,m}), anchors (^, $, \b), lookaheads ((?=...), (?!...)), and named capture groups. However, some features differ: Python's recursion ((?R)) isn't available, PCRE's conditional patterns ((?ifthen|else)) don't work, and possessive quantifiers (x++ JS 2024+) have limited support. For language-specific testing, check our tool output against your target runtime; the native engine ensures accuracy for JavaScript/TypeScript projects.
How do I test a regex written for C#, Java, or PHP here?
This tool runs JavaScript's native RegExp engine, which covers most shared syntax: character classes, quantifiers, anchors, lookaheads, and named groups. Watch for engine differences: C# allows variable-length lookbehind (JS requires fixed width), Java supports \Q...\E quoting, and PHP/PCRE offers recursion ((?R)) and conditionals; none of these exist in JS. Port the pattern to JS syntax first, then verify the result against your target runtime, since the same pattern can behave differently in C#, Java, PHP, or .NET.
Why does my regex match nothing even though it looks correct?
Check the invisible culprits first: trailing spaces or tabs in your test string, and line endings: a Windows file uses \r\n, so ^ and $ without the m flag anchor to the whole string, and . does not match \n unless the s flag is on. Then check escaping: a literal dot must be written as \., and any character that is special in regex (+, ?, (, [, {) needs a backslash when you mean it literally. If the pattern still fails, shrink it to a tiny test case and build it back up piece by piece.
How does replacement mode work?
In replacement mode, you provide a replacement string that uses special syntax to reference capture groups:
• `$&` or `$0`: the entire match
• `$1`, `$2`, `$3`: numbered capture groups (1-indexed)
• `$<name>`: named capture groups (ES2018+)
• `` $` ``: everything before the match
• `$'`: everything after the match
• `$$`: literal dollar sign
For example, pattern `(\w+)@(\w+)` with replacement `$2@$1` swaps the parts around each @ symbol. Test complex replacements here before deploying to production.
Can I test regex performance or detect catastrophic backtracking?
The tool displays processing time for each match operation. If you notice extreme slowdown (seconds instead of milliseconds) with certain inputs, you may have encountered catastrophic backtracking: a situation where the regex engine explores exponentially many possibilities before failing. Common triggers: nested quantifiers like `(a+)+`, overlapping alternation, and quantifiers on optional groups. To diagnose: simplify your pattern, use atomic groups or possessive quantifiers where available, or restructure to avoid ambiguous branching. The real-time feedback helps catch performance issues before they hit production.
What is the difference between greedy and lazy quantifiers?
Greedy quantifiers (*, +, {n,}) match as much as possible. Lazy quantifiers (*?, +?, {n,}?) match as little as possible. For example, on 'abc123': /\w+\d+/ matches 'abc123' (greedy, eats all), while /\w+?\d+/ matches 'abc1' (lazy, takes minimum before \d+). Use lazy quantifiers to avoid matching too much.
How do I match Unicode characters including emoji with regex?
Use the 'u' (Unicode) flag and Unicode property escapes. For example: \p{Emoji} matches any emoji, \p{Script=Han} matches Chinese characters, \p{L} matches any Unicode letter. Without the 'u' flag, \d and \w only match ASCII characters. With the 'u' flag, they match full Unicode.
How is this different from Regex101?
Regex101's edge is engine breadth: it tests PCRE, Python, Go, Java, and .NET flavors side by side, with an explanation panel and a community library. This tool is JavaScript-only (results match your production JS exactly), runs fully offline with zero uploads (paste passwords or PII without worry), and its Replace mode, common-pattern library, and catastrophic-backtracking timing are built in. If you need multi-engine comparison, Regex101 fits better; if you write JavaScript and care about privacy, this one.