Skip to developer tool
DEVELOPER TOOLKIT CODE & FORMATTING

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

BUILT FOR THE DETAILS
  1. 01Add your input
  2. 02Inspect & adjust
  3. 03Use your result
Browse developer tools
LOCAL-FIRST · JAVASCRIPT RegExp

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.

Worker deadline: 1.3 seconds per job · max input 120,000 UTF-16 units · display cap does not cap replacement
Text stays in this browser · never executed as code
Highlighted matches
Run regex to see matches
Select a match to inspect its captures.
Ready · JavaScript engine · all source remains local
Indices use UTF-16 code units; capture spans require flag d.
Replacement preview
Preview only—your source is not modified.
Match explorer & explanation

Match selection and groups

Run a pattern to inspect groups.

What does this pattern contain?

Explanations cover common tokens only; advanced syntax remains subject to the native JS engine.
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.

No files selected.
Escaping is not sanitization. Time limits do not prove production regex safety.

How to use JavaScript Regex Tester

  1. Enter a pattern without slash delimiters and choose JavaScript flags.
  2. Paste sample text and a replacement string. Use Escape literal pattern when your pattern should match punctuation literally.
  3. 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

Original JavaScript-regex practice setup
FieldEnter
Sample textORDER-12 ORDER-34
Pattern, without enclosing slashesORDER-(\d+)
FlagsEnable g for both occurrences.
ReplacementPO-$1
  1. Test this authored sample and inspect the full matches, capture group values and replacement text. Group 1 represents the digits in each match.
  2. Compare with g disabled to understand first-occurrence replacement. Do not assume a match-count limit changes JavaScript replacement semantics.
  3. Add a nonmatching example from your own data and check boundaries before adapting the expression to an application.
  4. Use Escape literal pattern when text such as a filename should be matched literally rather than interpreted as regex syntax.
  5. 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.

Related next steps

All developer tools · Privacy policy · Contact PixelOkay