.*

Regex Tester and Explainer

Test a JavaScript regular expression: highlighted matches, capture groups, replace, split and a plain-English explanation.

How it works

Type a pattern, pick the flags and paste your text. Every match is highlighted, and a table lists each match with its position and capture groups (named groups show their name). Pick Replace to preview a substitution using $1, $2 or $<name>, or Split to cut the text at each match.

The explainer under the results reads your pattern one piece at a time in plain words. This tool uses the regex engine of your own browser (the JavaScript flavour), the same one used in Node.js and web pages.

  1. Pick a ready pattern or type your own.
  2. Set flags: g finds all matches, i ignores case, m makes ^ and $ work per line, s lets . match line breaks, u turns on Unicode.
  3. Paste the text to test against.
  4. Read the matches, groups and the explanation.

Worked example

Pattern (?<day>\d{2})/(?<month>\d{2})/(?<year>\d{4}) on "Exam on 05/12/2026" gives one match at position 8 with day=05, month=12, year=2026. In Replace mode with $<year>-$<month>-$<day> it becomes "Exam on 2026-12-05".

Good to know

Common questions

What do the flags mean?
g all matches, i ignore case, m ^ and $ match at every line, s dot matches line breaks, u full Unicode, y sticky (match only at the current position), d also report indices.
Why do I get only one match?
Without the g flag a regex stops after the first match.
What is a capture group?
Anything in ( ). The text it matched is saved and can be reused in a replacement as $1, $2, or by name as $<name>.
Why does my pattern work here but not in Python or Java?
Each language has small differences. Check its own documentation for named groups and lookbehind.
What is the difference between greedy and lazy?
Greedy (.*) matches as much as it can, lazy (.*?) as little as it can. On <b>a</b><b>b</b> the pattern <b>.*</b> takes everything but <b>.*?</b> takes one tag pair.

More in Developer.