Regex Tester
Test JavaScript regex patterns, inspect matches and capture groups, preview replacements and compare the changed text. Choose flags to control matching.
Test JavaScript regex patterns, inspect matches and capture groups, preview replacements and compare the changed text. Choose flags to control matching.
- Prepare your input
Choose the relevant options using the controls below.
- Run your task
Adjust the controls below and inspect the preview.
- Use the result
Check the result, then use the available copy or download controls.
Fill in the fields and run the operation to see the result.
Regex Tester
Try a JavaScript regular expression against sample text before using it in code. Enter the pattern without enclosing / delimiters and select flags separately. For example, \d+ with the g flag finds 12 and 34 in order 12, item 34. Without g, matching stops after the first result.
Use Replace to preview a replacement or Diff to compare the source and changed text. Numbered groups use $1, $2 and so on in replacements. The m flag changes how ^ and $ treat line boundaries; s lets a dot match newline characters. This tool uses JavaScript RegExp, not PCRE or Python syntax. The match list displays at most 1,000 entries; the total count may be larger.
Features
- Run JavaScript regex patterns with g, i, m, s, u and y flags.
- Inspect matching text, positions and numbered or named capture groups.
- Preview replacements and compare the result with the input.
- View the total match count and measured execution time; copy replacement output.
How to use
- Enter a pattern such as \d+ without surrounding slashes and enable g.
- Paste order 12, item 34 into the input and run; the two matches should be 12 and 34.
- Switch to Replace and enter # to preview order #, item #; use Diff to inspect the changes.
- Review groups and flags before copying the result. A match here confirms behavior for the supplied example, not every possible input.