Skip to main content

Regex tester

Test and debug regular expressions as you type. Matches are highlighted in your text, and capture groups are listed.
Test a regex pattern
Enter a pattern and see the matches as you type
//g

0 characters

Matches foundNo matches
Regex examples
Click an example to load it
Regex cheat sheet
The most common regex symbols at a glance

Character classes

  • . Any character
  • \d Digit [0-9]
  • \w Word character [a-zA-Z0-9_]
  • \s Whitespace
  • [abc] a, b, or c
  • [^abc] Not a, b, or c

Quantifiers

  • * 0 or more
  • + 1 or more
  • ? 0 or 1 (optional)
  • {n} Exactly n times
  • {n,} n or more
  • {n,m} n to m times

Anchors and groups

  • ^ Start of text (with flag m: start of line)
  • $ End of text (with flag m: end of line)
  • \b Word boundary
  • (abc) Group
  • (?:abc) Non-capturing group
  • a|b a or b

How to test a regex in four steps

  1. Enter your pattern in the 'Regular expression' field, for example [a-z]+.
  2. Turn on the flags you need. 'g' is selected by default.
  3. Paste the text you want to search into the 'Test string' field.
  4. The matches appear highlighted, and the tool lists each one below.

If you'd rather not start from scratch, load an example. There are ready-made patterns for email addresses, URLs, US phone numbers, dates, IPv4 addresses, hex colors, HTML tags, and capitalized words.

How to read the match list

  • A badge shows the number of matches or 'No matches'.
  • The table gives each match a running number, its text, and its index. The index is the position in the test string and starts at 0.
  • Capture groups appear as $1, $2, and so on. Named groups such as (?<year>\d{4}) show their name next to the number, for example $1 (year). A group that didn't take part in the match shows (not set).
  • 'Copy' next to the pattern puts the pattern on your clipboard.
  • A match with no characters appears as ∅ in the list.
  • Without the 'g' flag, the tool returns only the first match.

What the regex tester can and can't do

The tester uses the regex engine of your browser, which means JavaScript. Patterns written for PHP, Python, or other languages only work if they fit JavaScript syntax.

The available flags are g, i, m, s, u, y, and, if your browser supports it, v. The flags u and v exclude each other, and the tool turns off whichever one you didn't just select. The tool doesn't offer the d flag (match indices).

The check runs in a Web Worker, separate from the page. If it takes longer than 750 milliseconds, the tester stops it and shows a message. The time counts only from the moment the worker is ready, so a slow start doesn't cause a stop. This typically happens with nested repetition such as (a+)+ on long text.

Common regex mistakes

  • A dot stands for any character. To match a literal period, write \.
  • A pattern like .* takes as much text as possible. With .*? you get the shortest match.
  • The message about an invalid regular expression usually points to an unclosed bracket or a misplaced quantifier.

Frequently asked questions

Everything about regular expressions
What are regular expressions (regex)?
Regular expressions are character patterns used to search, validate, and change text. Most programming languages and many text editors support them.
What are regex used for?
Common uses are validating email addresses and phone numbers, search and replace, extracting data from text, parsing URLs, and filtering log files.
What do the regex flags mean?
g (global) finds all matches instead of only the first. i (case insensitive) ignores upper and lower case. m (multiline) lets ^ and $ match at the start and end of each line. s (dotall) lets . match line breaks too. u (unicode) turns on full Unicode support, for example \p{L} and \u{1F600}. v (unicodeSets) extends u with set operations in character classes and only appears if your browser supports it. y (sticky) only allows a match exactly at the current position. u and v can't be combined.
What are common regex patterns?
\d matches a digit, \w a word character, \s whitespace, and . any character. * means zero or more repetitions, + one or more, and ? optional. [] defines a character class and () a group.
How do I test my regex?
Type your pattern into the regular expression field and paste the text to search into the test string field. The tool highlights every match in the text and lists each one in a table.
Can I also replace text with the regex tester?
No. The tester shows matches, positions, and groups, but it has no replace test. To try a replacement pattern with $1 or $<name>, use your own environment or the replace function in your code.
Is the regex tester free, and is my text sent anywhere?
It is free and needs no sign-up. The check runs in your browser, in a Web Worker on the page. The tool doesn't send your pattern or text to a server and doesn't store them.

Related tools

All tools

Changelog

Latest updates and improvements to the Regex tester
v1.3.0

November 20, 2026

Named groups, fair time limit, and corrected anchors

  • • Added: named groups show their name next to the number in the match list, for example $1 (year)
  • • Fixed: the 750 millisecond time limit started when the worker started. On slow devices, a harmless pattern could trigger a timeout. The time now counts from the start of the evaluation
  • • Corrected: the cheat sheet listed ^ and $ as start and end of line. Without the m flag, they stand for start and end of text
  • • The FAQ now says the tester has no replace test
v1.2.0

November 18, 2026

Flags u, v, and y

  • • Added the flags u (unicode), y (sticky), and, if the browser supports it, v (unicodeSets)
  • • u and v exclude each other: turning one on turns the other off
  • • With u or v, empty matches skip a whole character outside the basic alphabet, such as an emoji
v1.1.0

November 17, 2026

Guide and related tools

  • • Added a guide with instructions and use cases below the tool
  • • Added related tools at the end of the page
Show older versions
v1.0.0

December 8, 2025

Launch

  • • Live regex testing
  • • Highlighting of matches
  • • Support for the flags g, i, m, and s
  • • Display of capture groups
  • • Ready-made regex examples
  • • Error handling for invalid patterns