/ /
0 matches

Match information

Copy

About the Regex Tester

What is a regex tester?

A regex tester lets you write a regular expression and instantly see what it matches in a block of text, without running any code. Type a pattern, paste your test string, and every match lights up as you go — with a full breakdown of the capture groups underneath. It turns the usual trial-and-error of "does this pattern actually work?" into something you can watch happen live.

This one runs on the JavaScript regex engine, right in your browser, so nothing you type is ever sent anywhere. You get all six flags as one-click toggles, a match inspector that shows positions and both numbered and named groups, a substitution panel for testing find-and-replace, and a library of ready-made patterns for the things people match most. It's built for everyone from someone learning their first character class to a developer debugging a gnarly lookahead.

How to Use This Tool

  1. Enter your pattern. Type your regex into the expression field — no surrounding slashes needed. Toggle the flags (g, i, m, s, u, y) to change how it matches.
  2. Add a test string. Paste the text you want to search. Matches highlight instantly, and the match count shows in the corner.
  3. Inspect the matches. The panel on the right lists every match with its position and each capture group, including named groups.
  4. Try a replacement. Flip on Substitution to test a find-and-replace, using $1 or $<name> to insert captured text.
  5. Start from a sample. Pick a ready-made pattern from the dropdown, then copy your finished regex with one click.

Common Use Cases

Regular expressions show up everywhere text needs to be searched, validated, or reshaped:

  • Validating input: Check that an email, phone number, password, or postcode matches the format you expect before you accept it.
  • Extracting data: Pull every URL, date, price, or ID out of a log file, a CSV, or a wall of scraped text.
  • Find and replace: Reshape text in bulk — reformat dates, strip tags, or swap one pattern for another using capture groups.
  • Search in code editors: Build and verify the pattern before pasting it into VS Code, grep, sed, or a database query.
  • Learning regex: Watching matches light up as you tweak a pattern is the fastest way to understand how each token behaves.

Need to tidy your text first? Try the Text Cleaner or Find and Replace Text tool, or browse all our free developer tools.

Regex Cheatsheet

A quick reference for the tokens you'll reach for most often:

TokenWhat it matches
.Any single character except a newline.
\d / \DAny digit / any non-digit.
\w / \WAny word character (letter, digit, underscore) / its opposite.
\s / \SAny whitespace / any non-whitespace.
[abc] / [^abc]Any one of a, b, c / any character except those.
^ / $Start / end of the string (or line, with the m flag).
* + ?Zero or more, one or more, or zero or one of the previous token.
{2,5}Between 2 and 5 of the previous token.
(abc)A capturing group you can reference or extract.
(?:abc)A non-capturing group (groups without capturing).
(?<name>abc)A named capturing group.
a|bMatches a or b (alternation).
\bA word boundary.
(?=...) / (?!...)Positive / negative lookahead.

Frequently Asked Questions

What is a regular expression?

A regular expression, or regex, is a compact pattern that describes a set of strings. Instead of searching for one fixed word, you describe a shape — "three digits, a dash, then four digits" — and the engine finds every piece of text that fits. It's a standard tool in almost every programming language for searching, validating, and transforming text.

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

They change how the pattern is applied. g (global) finds every match instead of just the first; i makes it case-insensitive; m (multiline) lets ^ and $ match at each line break; s (dotall) lets . match newlines too; u turns on full Unicode handling; and y (sticky) only matches starting exactly where the last match ended.

What is a capture group?

Parentheses around part of a pattern create a capture group, which remembers the text it matched so you can pull it out or reuse it. This tool lists every group under each match. Use (?:...) when you want to group tokens without capturing, and (?<name>...) to give a group a readable name.

How does the substitution (find & replace) feature work?

Turn on Substitution and type a replacement string. You can insert captured text with $1, $2, and so on, use $<name> for named groups, or $& for the entire match. Remember to add the g flag if you want every match replaced rather than just the first.

What's the difference between greedy and lazy quantifiers?

By default quantifiers are greedy: .* grabs as much as it can. Adding a ? makes them lazy, so .*? grabs as little as possible. Lazy quantifiers are handy when you want the shortest match, like the text between the nearest pair of quotes or tags.

Why isn't my pattern matching across multiple lines?

Two different flags control line behavior. The m flag makes ^ and $ match at the start and end of each line, while the s flag makes . match newline characters. If your pattern should span line breaks, you usually want the s flag.

How do I match an email address or a URL?

A reliable email pattern is \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b, and a simple URL pattern is https?://[^\s]+. Both are in the sample dropdown so you can load them and tweak them against your own text.

Which regex flavor does this tester use?

It uses the JavaScript (ECMAScript) regex engine, the same one that runs in every web browser and in Node.js. Most syntax is shared across languages, but a few features differ from PCRE, Python, or Java — lookbehind, for instance, is supported in modern browsers but written slightly differently in other flavors.

Is my data private?

Completely. The tester runs entirely in your browser with JavaScript, so your patterns and test strings are never uploaded, stored, or logged. You can safely test against sensitive data, and the tool keeps working offline once the page has loaded.