JavaScript Regex Tester
Explore JavaScript regular expression behavior against your own text. View captures and replacements while a worker deadline bounds patterns that take too long.
Browser-based · No account required · Copy and export
Regex engineering workspace
Match, inspect captures, test revisions and preview replacements in a time-limited browser Worker. This is not a PCRE engine or a guarantee of production safety.
d.Match explorer & explanation
Match selection and groups
What does this pattern contain?
Regression test cases
Build positive and negative examples. Test cases run in the same disposable worker as the main regex.
Revision comparison & saved patterns
Compare a baseline pattern
Pattern library
Saving is opt-in and stores only named patterns, flags and replacement—never sample text automatically.
Local batch text replacement
Choose up to 16 UTF-8 files (600 KB combined). Each is processed with this pattern and replacement. Files stay on-device; generated ZIP contains replacement results and a summary.
How to use JavaScript Regex Tester
- Enter a pattern without slash delimiters and choose JavaScript flags.
- Paste sample text and a replacement string. Use Escape literal pattern when your pattern should match punctuation literally.
- Inspect highlighted matches and captures, then download the match report if needed.
When to use this tool
Test a JavaScript pattern against a representative input, inspect groups and try replacements. Results use JavaScript syntax; another language or database may interpret the same pattern differently.
Literal text and regular expression syntax differ
Characters such as dots, brackets and plus signs have special meanings in a pattern. Escaping literal text converts those characters to literal matches. Replacement syntax is separate: $& refers to the full match and named captures can use $<name>. Results use JavaScript semantics rather than PCRE or another server engine.
Worked example
Literal input: a+b.txt
Escaped pattern: a\+b\.txt
Named capture: (?<word>\w+)
Replacement: [$<word>] Check captures and replacement on a small representative sample
| Field | Enter |
|---|---|
| Sample text | ORDER-12 ORDER-34 |
| Pattern, without enclosing slashes | ORDER-(\d+) |
| Flags | Enable g for both occurrences. |
| Replacement | PO-$1 |
- Test this authored sample and inspect the full matches, capture group values and replacement text. Group 1 represents the digits in each match.
- Compare with g disabled to understand first-occurrence replacement. Do not assume a match-count limit changes JavaScript replacement semantics.
- Add a nonmatching example from your own data and check boundaries before adapting the expression to an application.
- Use Escape literal pattern when text such as a filename should be matched literally rather than interpreted as regex syntax.
- Review the report and your destination engine's behavior. A timeout means processing stopped, not that the pattern had no matches.
Expected capture/replacement exercise, not a freshly executed result. Positions use JavaScript UTF-16 indexing, and other regex engines can differ. Use Text Diff to inspect a proposed replacement before applying it elsewhere.
Build a reusable regex test suite
Add named positive and negative examples from the current sample, run them in individually time-bounded browser Workers, and export the case results. Compare a baseline pattern against a revision on one sample before adopting a change. This checks examples, not all possible inputs.
Copy, export and hand off a JavaScript regex
Download current match records as JSON, CSV or Markdown, export replacement text without altering the source, and save a portable project containing your test cases. The optional named-pattern library stores only patterns and settings, not sample texts. Exported projects and reports can include private input, so inspect before sharing.
Limits and output checks
Processing has a worker deadline and a bounded match count. A timeout means the computation was stopped, not that the pattern has no matches. Match positions follow JavaScript UTF-16 indexing. The report contains visible matches, not a complete regex compatibility audit.
Reference: JavaScript regular expressions.
Frequently asked questions
Should I include / around the pattern?
No. Enter just the pattern and select flags with the controls.
Does literal escaping change replacement text?
No. It changes only the pattern input, then reruns the existing worker-based tester.
Does a timeout freeze the page?
Pattern evaluation runs in a worker that is terminated when its deadline expires. Reduce the input or revise an expensive pattern.
A practical workflow
Use a representative text sample to inspect captures and replacement output before adapting the expression to your application.
Read the scope alongside the result
JavaScript behavior can differ from another regex engine. A timeout does not mean no match, and positions use JavaScript UTF-16 indexing.