Skip to content

Regex Tester for JavaScript Regular Expressions

Write a pattern, paste some text and watch the matches light up as you type. Capture groups, flags and replacements are all shown, and nothing leaves your browser.

Flags

Uses your browser's JavaScript regex engine (ECMAScript), the same one as Node.js.

Matches in your text

Contact ali.khan@example.com or support@fileora.tools for help. Invalid: user@localhost

How to test a regular expression

  1. Type your pattern into the Regular expression box, without the surrounding slashes. A sample pattern that finds email addresses is loaded to start with.
  2. Choose flags by tapping g, i, m, s, u or y. The active flags are shown after the closing slash.
  3. Paste your test text. Every match is highlighted in the box on the right, with a count above it.
  4. Optionally add a replacement, such as $1 or $<name>, to preview the text after replacing.
  5. Check the match details table for the position of each match and the value of every capture group.

Features

  • Live highlighting of matches as you type.
  • All six JavaScript flags: global, ignore case, multiline, dot-all, Unicode and sticky.
  • Capture groups in a table, with named groups shown under their own names.
  • Replace preview supporting $1, $<name> and $&, with a copy button.
  • Match count and positions, with the first 1,000 matches listed.
  • Protection against runaway patterns: evaluation runs in a Web Worker and is stopped after 1.5 seconds.
  • Clear error messages from the engine when a pattern is invalid, such as an unclosed group.

Why use Fileora's regex tester

Test data is often real data: server logs, customer exports, email lists. Fileora runs the regular expression in your browser, so none of it leaves your device. It is free, has no sign-up, and the flag buttons are large enough to use comfortably on a phone.

Because the tester uses the same engine as your JavaScript code, there are no surprises when you copy the pattern into your project.

JavaScript regex cheat sheet

  • . any character except a line break (any character at all with the s flag)
  • \d, \w, \s a digit, a word character (letter, digit or underscore), a whitespace character
  • \D, \W, \S the opposite of each of the above
  • [abc], [^abc], [a-z] one character from a set, not in a set, or in a range
  • ^ and $ start and end of the text, or of each line with the m flag
  • \b a word boundary
  • *, +, ? zero or more, one or more, zero or one
  • {3}, {2,5} exactly 3 times, or between 2 and 5 times
  • *?, +? lazy versions that match as little as possible
  • (abc) a capture group; (?:abc) a group that doesn't capture
  • (?<year>\d{4}) a named group, used as $<year> in a replacement
  • a|b either a or b
  • (?=x), (?!x) followed by x, not followed by x
  • (?<=x), (?<!x) preceded by x, not preceded by x
  • \p{L} any letter in any script, with the u flag, useful for Urdu and Hindi text

Avoiding slow patterns

Catastrophic backtracking usually comes from a repeated group that contains another repeat, like (a+)+ or (\w+\s?)*. Make each part match something distinct, anchor the pattern with ^ and $ where possible, and prefer specific character classes over .*.

To check the effect of a replacement on a long file, compare before and after in the diff checker, and tidy up extracted JSON with the JSON formatter.

Frequently asked questions

Which regex flavour does this tester use?

It uses your browser's own JavaScript regular expression engine, which follows the ECMAScript standard and behaves the same as Node.js. Patterns that work here will work in JavaScript and TypeScript code. Other flavours such as PCRE, Python or .NET have some different syntax and features, so test those in their own environment.

What do the flags g, i, m, s, u and y do?

g finds all matches instead of only the first. i ignores upper and lower case. m makes ^ and $ match at the start and end of every line. s lets the dot match line breaks. u turns on full Unicode mode, needed for things like \p{L}. y (sticky) only matches at the exact position where the last match ended.

How do I use capture groups in the replacement?

Type a replacement in the Replace with box. Use $1, $2 and so on for numbered groups, $<name> for a named group, and $& for the whole match. The Result after replace box shows the full text with every replacement applied, and you can copy it.

Why was my pattern stopped for taking too long?

Some patterns, such as (a+)+ followed by something that doesn't match, make the engine try an enormous number of combinations. This is called catastrophic backtracking. The tester runs each pattern in a separate background worker and stops it after 1.5 seconds so the page never freezes. Rewrite the pattern so that nested repeats can't match the same text in different ways.

Is there a limit on the number of matches?

The total number of matches is always counted and shown, but the Match details table lists the first 1,000 to keep the page fast. Highlighting in the text covers the same first 1,000 matches.

Is my test text sent to a server?

No. Patterns and text are processed in a Web Worker inside your browser. Nothing is uploaded or stored, so you can test against log files or data that contains personal information.

Can't find the tool you need, or something isn't working?

Tell us which tool you'd like next or what went wrong. We read every message, and requests decide what we build next.

Opens your email app. Please don't attach private files.