GenerateIt

RegEx Tester

Regular expressions (often shortened to regex or regexp) are a powerful and flexible way to search, match, extract, and manipulate text. By defining a specific pattern made up of ASCII or Unicode characters, you can quickly identify one or more matches within large blocks of text that would otherwise be difficult to process manually.

Regex is widely used across many applications, including input validation, string parsing and replacement, data transformation, log analysis, and web scraping. Whether you are checking if an email address is valid, extracting values from structured text, or reformatting content, regular expressions provide an efficient and precise solution.

With this tool, you can enter a regular expression and test it instantly against your own sample text to see exactly how it behaves. Matches are highlighted in real time, allowing you to fine-tune your pattern and understand the results more clearly. If you’re new to regex or just need a quick reference, you can also scroll down to try one of the built-in examples and see how common patterns work in practice.

This regex tester is ideal for developers, students, and anyone working with text who wants a fast, visual, and interactive way to experiment with regular expressions and improve accuracy.

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong.

Buy me a coffee

Test your expression

Flags

Enter a regular expression above.

Results

Everything is worked out in your browser and nothing is uploaded. This tool uses the JavaScript regular expression syntax.

Examples to try

Try some of the examples below to get a feel for how this RegEx Tester works. Click Try and the expression and a piece of sample text are put in the fields above. Play around with the regular expressions and you will soon see what is happening.

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong.

Buy me a coffee

About regular expressions

Learn more about regex with the cheat sheet below, which explains the characters used in regular expressions. It follows the JavaScript syntax used by this tool.

Special characters

^
Matches at the start of the text. With the multiline flag it also matches at the start of every line.
$
Matches at the end of the text. With the multiline flag it also matches at the end of every line.
.
Matches any character except a line break. With the dot all flag it matches line breaks too.
\
Escapes a special character, so \. matches a real dot, or starts a character class such as \d.
A|B
Matches A or B. If A matches, B is not tried.
+
Matches the expression to its left 1 or more times, as many as possible (greedy).
*
Matches the expression to its left 0 or more times (greedy).
?
Matches the expression to its left 0 or 1 times. Added after +, *, ? or {m,n} it makes the match lazy, so it takes as few as possible.
{m}
Matches the expression to its left exactly m times.
{m,n}
Matches the expression to its left from m to n times. {m,} means m or more.
{m,n}?
The lazy version of {m,n}: it matches as few times as it can.

Character classes

\w
Matches letters, digits and the underscore (a-z, A-Z, 0-9, _).
\W
Matches anything that \w does not.
\d
Matches a digit (0-9).
\D
Matches any character that is not a digit.
\s
Matches white space, such as a space, \t, \n and \r.
\S
Matches any character that is not white space.
\b
Matches a word boundary, the position between a \w and a \W (or the start or end of the text).
\B
Matches a position that is not a word boundary.
\n \t \r
Match a new line, a tab and a carriage return.
\uXXXX
Matches the character with that four-digit hex code, for example \u00e9. With the Unicode flag, \u{1F600} also works.
\p{L}
With the Unicode flag, matches a letter from any language. Other examples are \p{Lu} (capital letter), \p{N} (number) and \P{L} (not a letter).

Sets

[ ]
Contains a set of characters to match.
[abc]
Matches a, b or c (not abc).
[a-z]
Matches any character from a to z.
[a\-z]
Matches a, - or z.
[a-]
Matches a or -.
[-a]
Matches a or -.
[a-z0-9]
Matches characters from a to z and 0 to 9.
[(+*)]
Matches a literal (, +, * or ). Most special characters lose their meaning inside a set.
[^ab5]
Matches any character except a, b or 5.

Groups and look-around

( )
Groups the expression inside, and captures what it matched as $1, $2 and so on, counted by the opening bracket.
(?:A)
Groups A without capturing it.
(?<name>A)
A named group. Matches A and also captures it under the name, which you can use in the replace field as $<name>.
\1
Matches the same text that group 1 matched. \2, \3 and so on work the same way.
\k<name>
Matches the same text that the named group matched earlier.
A(?=B)
Positive lookahead. Matches A only if B comes straight after.
A(?!B)
Negative lookahead. Matches A only if B does not come straight after.
(?<=B)A
Positive lookbehind. Matches A only if B comes straight before.
(?<!B)A
Negative lookbehind. Matches A only if B does not come straight before.

Replace field

$1, $2 …
The text captured by that group.
$<name>
The text captured by a named group.
$&
The whole match.
$`
The text before the match.
$'
The text after the match.
$$
A literal dollar sign.

How to use it

The online regex tester is a handy tool to help you learn and check regex codes before using them in your projects.

  1. Look at the examplesIf you are new to regex, try a few of the examples on this page just to get a feel of how they work.
  2. Enter the expressionType the regular expression into the field at the top. You do not need the slashes around it.
  3. Choose the flagsSelect which flags you want, such as Global to find every match or Ignore case.
  4. Add your textPaste or type the test data into the text box.
  5. Check the matchesThe matches are highlighted as you type, and each one is listed with its position and captured groups. Fill in the replace field to see the text after replacing.

Good to know

JavaScript syntax

The expression runs with the JavaScript regex engine. Other languages, such as PHP or Python, can differ a little, for example in named groups and in the flags.

Runaway patterns

Some patterns, such as (a+)+b, can take a very long time on certain text. The tester stops after 2 seconds instead of freezing the page.

Empty matches

Patterns such as a* can match nothing at all. These are shown as empty matches and are not highlighted.

Frequently asked questions

Which regex flavour does this tester use?

The one built into your browser, which is the JavaScript flavour. Most of the common syntax is the same as in PHP, Python and other languages, but some features differ, so check the details when you move an expression to another language.

What do the flags do?

Global finds every match instead of only the first. Ignore case treats capital and small letters alike. Multiline makes ^ and $ match at each line. Dot all lets the dot match a new line. Unicode turns on full Unicode support, including \p{L} classes.

How do I use groups in the replace field?

Put brackets around the part you want to reuse, then write $1, $2 and so on in the replace field. Named groups written as (?<name>…) are used as $<name>. Use $& for the whole match and $$ for a dollar sign.

Why does it say the expression was stopped?

Some patterns try a huge number of ways to match and take very long on certain text. After 2 seconds the tester gives up so your browser keeps working. Making the pattern more specific, or avoiding repeats inside repeats, usually fixes it.

Is my text uploaded?

No. The matching is done in your browser and nothing is sent anywhere.

Related tools

CSS Gradient Generator

Easily create CSS gradients using this online generator. You'll be able to create either linear or radial gradients.

CSS Grid Generator

Easily generate CSS grid layout. This grid generator will include footer, header and columns.

CSS Layout Generator

This generator will create a fluid or fixed width column layout, with up to 3 columns + header, footer and menu.

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong.

Buy me a coffee