DEVELOPER TOOL

Regex Tester

Test JavaScript regular expressions against text.

[]

About Regex Tester

Regular expressions are easiest to get right by trying them on real text. Type a pattern in the first box, paste sample text in the second, and the matches appear below straight away as a JSON array. Edit either box and the list refreshes, so you can tighten a pattern one character at a time.

The pattern is compiled with the same engine your browser uses for JavaScript, so what works here will behave the same in front-end code and in Node. The global flag is always on, which means you see every non-overlapping match in the text rather than just the first. The box starts with a simple email-like pattern so you can see the format of the results right away.

This is a focused tester. It lists the full matched text only. It does not highlight positions, show capture groups, or let you add flags such as case-insensitive or multiline, so it is best for confirming what a pattern finds and for catching syntax mistakes.

How to use Regex Tester

  1. Click the single-line pattern box and enter your regular expression without surrounding slashes or flags, for example \d+ to find numbers.
  2. Click the larger text box and paste or type the sample text you want to search.
  3. Read the output below. Matches appear as a JSON array in order of appearance, and an empty array means nothing matched.
  4. Adjust the pattern until the list contains exactly what you expect. If an error message appears instead, fix the syntax problem it describes.

When this tool helps

Writing a validation pattern

Before adding a pattern to a form, paste a set of valid and invalid sample values and check which ones come back as matches. It is a quick way to see whether the pattern is too loose or too strict.

Extracting values from a log

Paste a block of log lines and try a pattern for request IDs, timestamps, or error codes. Seeing the list of matches tells you whether the pattern picks up everything and nothing extra.

Planning a find-and-replace

Before running a bulk replacement in an editor or script, test the search pattern here against a sample. Catching a greedy match now is easier than undoing a change across a whole project.

Debugging a pattern that fails

If your code throws an error for a pattern, paste it in. An invalid expression shows the engine's error message, often naming the unterminated group or bad escape that needs fixing.

Tips for better results

  • Type the pattern body only. Slashes around it are not needed, and a trailing flag letter will be treated as part of the pattern rather than as a flag.
  • Without the multiline flag, ^ and $ match only the start and end of the whole text. To work line by line, use a different approach such as matching a line's content directly.
  • For case-insensitive matching, there is no flag option here, so use character classes like [Aa] in the pattern, then add the i flag when you move it into your code.
  • Include tricky samples in the text: empty values, extra spaces, very long strings, and near-misses. Good test text finds problems that a few tidy examples never will.

Good to know

  • The global flag is always applied and you cannot add others, such as case-insensitive, multiline, dotAll, or unicode.
  • Only the full matched strings are listed. Capture groups, match positions, and replacement previews are not shown.
  • Patterns with heavy backtracking can make the page unresponsive, because the regular expression runs on every edit.

Privacy and your data

The expression and sample text are evaluated in your browser. Nothing you enter is sent to a server by this tool.

Regex Tester FAQ

Which regex flavor does this tester use?

JavaScript, using the browser's built-in regular expression engine. Features like lookbehind and named groups depend on your browser version. Patterns written for other flavors, such as PCRE or Python, may behave differently, especially with inline modifiers, possessive quantifiers, and some character class shortcuts.

Why do I only see the matched text and not capture groups?

The tester runs a global match, which returns each full match as a string and drops group details. To inspect groups, use the matchAll method in your own code or a testing tool that lists them. This page is for checking what a pattern finds.

How do I make the search case-insensitive?

There is no flag field here, so write both cases into the pattern, for example [Hh]ello, to test the logic. In your real code, add the i flag after the closing slash or pass it as the second argument to the RegExp constructor.

Why does my pattern show an empty array?

An empty array means the pattern is valid but found no match in the text. Check for escaping mistakes, such as a single backslash that should be doubled in a string, extra spaces, and anchors like ^ and $ that limit matches to the whole text.

What does an error message here mean?

The pattern could not be compiled. Common causes are an unclosed parenthesis or bracket, a quantifier with nothing before it, or an invalid escape. The message comes straight from the engine, so read it for the specific problem and fix that part first.

Can a regex freeze the page?

Yes, in rare cases. Nested quantifiers such as (a+)+ on long, non-matching input can cause catastrophic backtracking, where the engine tries an enormous number of paths. If the page hangs, close the tab, then simplify the pattern before testing again.

Browse all ELDOSA tools →