Regex Tester

✓ 100% Free ✓ No Sign-Up ✓ Private by Design
Free · No sign-up · Runs in your browser

Regex Tester

Test patterns with highlighted matches and capture groups, replace with $1 references, or load a ready-made pattern.

Worked example: pattern (\d+)-(\d+) on the sample text finds 2026-12, 2026-11 and 150-25, with group 1 and group 2 listed for each.

Replace uses the same pattern, flags and test text from the Test tab. With the sample, $2/$1 turns 2026-12 into 12/2026.

Load a ready-made pattern

Regex cheat sheet

TokenMeaning
.Any character except newline (any at all with s flag)
\d \DDigit / non-digit
\w \WWord character (letter, digit, _) / non-word
\s \SWhitespace / non-whitespace
^ $Start / end of text or line (with m flag)
* + ?0 or more / 1 or more / 0 or 1
{n} {n,} {n,m}Exactly n / at least n / between n and m
[abc] [^abc] [a-z]Character class / negated class / range
(...) (?:...)Capture group / non-capturing group
a|bAlternation: a or b
\bWord boundary
(?=...) (?!...)Lookahead: followed by / not followed by
Was this helpful?

How to use the Regex Tester

  1. Type your regular expression without the surrounding slashes, or load one from the pattern library.
  2. Tick the flags you need and paste your test text to see matches highlighted and listed.
  3. Switch to Replace to build a replacement with $1 group references and copy the result.

Regex Tester FAQs

How do I test a regular expression?

Type the pattern without surrounding slashes — for example \d+ to find numbers — paste your test text, and the tool highlights every match instantly and lists each match with its capture groups. Tick the flags (g, i, m, s, u) to change how matching works.

What do the regex flags mean?

g finds all matches instead of stopping at the first; i ignores upper and lowercase; m makes ^ and $ match each line; s lets . match newlines too; u enables full Unicode mode. Combine them as needed, for example gi for a case-insensitive search across the whole text.

How does replace mode work?

Replace mode runs your pattern over the test text and swaps each match for the replacement text. Use $1, $2 and so on to insert capture groups, and $& for the whole match. For example, pattern (\d+)-(\d+) with replacement $2/$1 turns 2026-12 into 12/2026.

Why does my regex show an error?

The pattern itself is invalid — a common cause is an unclosed bracket or parenthesis, or a stray backslash at the end. The error message names the problem; fix that part of the pattern and the matches appear. Very long patterns on huge text can also be slow, so trim the test text if needed.

Is my test text sent anywhere?

No. Testing and replacing run entirely in your browser with JavaScript regular expressions, so your pattern and text never leave your device. That makes it safe for log lines, sample data and code snippets.

Free Regex Tester — Test, Replace and Learn Regular Expressions

This free regex tester checks your regular expression against any text and shows every match highlighted, counted and listed with its capture groups. A replace mode with $1 references, a library of ready-made patterns for emails, dates, URLs and more, and a plain-language cheat sheet make it a complete regular expression workbench.

How to use it, step by step

  1. Enter a pattern or load one from the library.
  2. Choose flags and paste test text.
  3. Inspect highlighted matches and capture groups.
  4. Use Replace mode to transform the text and copy the output.

Popular uses

  • Cleaning data: find and reformat dates, phone numbers and codes.
  • Validating input: test email, URL and password patterns before shipping.
  • Log analysis: pull matching lines and fields out of sample logs.
  • Learning regex: try each cheat-sheet token and watch matches change.
Scroll to Top