Regex Tester
Validate JavaScript regular expressions and inspect match positions, capture groups, and replacement results in real time.
Enter only the pattern without surrounding slashes. Backslashes are passed directly to JavaScript RegExp.
Supports multiple lines, Korean, Japanese, and Emoji. Indexes use JavaScript UTF-16 positions.
Match information
Match preview
Enter a pattern and test string to highlight matches.
Multiple test cases
Add several strings at once to compare matches and capture groups against the same pattern.
No test cases added yet.
Use JavaScript tokens such as $&, $1, $2, $<name>, and $$.
Replacement preview
—
Regex examples
These are simple format examples, not complete validators. Your test string is preserved.
JavaScript regex quick reference
Based on the current browser's JavaScript RegExp syntax.
Character classes
. any character
\d digit · \w word character
\s whitespace · [abc] setQuantifiers
* zero or more · + one or more
? zero or one
{n} exactly n · {n,m} rangeAnchors
^ start · $ end
\b word boundary · \B non-boundaryGroups
(...) capturing
(?:...) non-capturing
(?<name>...) namedLookaround
(?=...) positive ahead
(?!...) negative ahead
(?<=...) positive behindEscape
\. dot · \\ backslash
\t tab · \n newlinePrivacy: your pattern, test string, and replacement are processed only inside a browser Worker and are never uploaded or stored.
Share
What does the Regex Tester do?
It runs JavaScript regular expressions against test text, shows matches and capture groups, previews replacements, and supports checking multiple test rows. The existing syntax reference remains the detailed guide for supported constructs.
How to use it
- 1
Enter a pattern and flags
Use JavaScript regular-expression syntax without surrounding slash delimiters.
- 2
Add test text
Run the pattern against the main text and inspect highlighted matches and captures.
- 3
Check replacement or batch cases
Preview replacement output or add rows to compare which samples match.
Practical examples
Capture a date
Pattern: (?<year>\d{4})-(\d{2})-(\d{2})
Flags: gNormalize whitespace
Pattern: \s+
Replacement: single spaceProcessing rules and limitations
JavaScript behavior
Syntax and flags follow the JavaScript RegExp engine, not PCRE, Python, or .NET.
Execution safeguards
Pattern, text, matches, detail, highlighting, and replacement output are capped to keep the page responsive.
Global flag
Without g, JavaScript reports the first match; with g, matching continues until the configured safety limit.
Patterns and test data remain local
Regex execution runs inside a browser Worker. Patterns, test strings, and replacements are not uploaded or stored.
Frequently asked questions
Should I include /pattern/ delimiters?
No. Enter only the pattern and select flags separately.
Why does a PCRE expression fail?
JavaScript supports a different feature set and syntax from PCRE and other regex engines.
Can a regular expression freeze the page?
Some patterns are computationally expensive. The tool uses a Worker and limits, but patterns should still be tested with realistic input.
Related text and developer tools
Text Cleaner
Clean up whitespace and blank lines across multiple lines, and remove duplicate lines.
Open toolJSON Formatter
Format JSON for readability or remove unnecessary whitespace to minify it.
Open toolURL Encoder/Decoder
Convert a full URL or component with UTF-8 percent encoding.
Open toolCron Expression Generator
Build and explain five-field Cron expressions and preview upcoming runs by timezone.
Open toolOther popular tools
Reduce image file size
Reduce JPG, PNG, and WebP images by quality or target file size in your browser.
Open toolWord Counter
Count characters, non-whitespace characters, words, and lines instantly.
Open toolPassword Generator
Choose a length and character types, or build an easy-to-remember passphrase, for a secure password.
Open tool