Text & Developer tool

Regex Tester Online for Beginners

Type a pattern, paste some text and see every match highlighted.

  • Instant results
  • Working shown
  • No sign-up
  • Runs in your browser
ToolUpdates as you type
Try:

Checking…

Regex cheat sheet
.Any character except a line break
\d \DA digit 0-9 / not a digit
\w \WLetter, digit or _ / anything else
\s \SSpace, tab or line break / anything else
\bWord boundary (start or end of a word)
^ $Start / end of the text (or line, with m)
[abc]One of a, b or c
[^abc]Any character except a, b or c
[a-z0-9]A range of characters
a* a+ a?0 or more / 1 or more / 0 or 1
a{3} a{2,5} a{2,}Exactly 3 / 2 to 5 / 2 or more
a+? a*?Lazy: match as few as possible
(abc)Capture group, $1 in replace
(?<name>abc)Named group, $<name> in replace
(?:abc)Group without capturing
a|ba or b
x(?=y) x(?!y)x only if followed / not followed by y
(?<=y)x (?<!y)xx only if preceded / not preceded by y
\. \* \\A literal . * or \ (escape special characters)

Uses JavaScript regular expressions, tested in your browser. Python, Java and other languages share most of this syntax, with small differences.

How it works

This regex tester highlights every part of your text that matches a regular expression, as you type. It lists each match with its position and capture groups, lets you switch flags such as g, i and m, and can preview a replacement. A cheat sheet and ready-made examples, like email and Indian mobile number patterns, help you get started.

This regex tester online shows you exactly what a regular expression matches. Type a pattern, paste some test text, and every match is highlighted as you type. Each match is listed with its position and the value of every capture group.

How to test a regular expression online

  1. Pick an example, such as Email address, or type your own pattern between the slashes.
  2. Turn flags on or off. Keep g on to find every match.
  3. Paste or type your test text.
  4. Read the highlighted text and the list of matches. Group values appear as $1, $2 and so on.
  5. Tick Test a replacement to preview text.replace() with your pattern.

Type the pattern without the surrounding slashes. The tester adds them for you.

Regex examples

Pattern Matches Example match
\b[6-9]\d{9}\b A 10-digit Indian mobile number starting with 6 to 9 9876543210
\b\d{6}\b A 6-digit PIN code 500081
[\w.+-]+@[\w-]+(\.[\w-]+)+ A simple email address ravi.teja@example.com
\b(\d{2})-(\d{2})-(\d{4})\b A date in DD-MM-YYYY form, with day, month and year in groups 15-03-2026
^\d+\..*$ with flag m Lines that start with a number and a dot 1. Install Python
\bjava\b with flag i The word Java in any case, but not JavaScript JAVA

For example, with the date pattern on the text "Exam on 15-03-2026", the tester shows one match at position 8 with $1 = "15", $2 = "03" and $3 = "2026".

Common mistake: A common mistake is forgetting to escape special characters. In .com, the dot means "any character", so it also matches "xcom". Write \.com to match a real dot. The same goes for + * ? ( ) [ ] { } ^ $ | and \.

Flags

Flag Name What it does
g global Finds every match instead of stopping at the first
i ignore case java also matches Java and JAVA
m multiline ^ and $ match at the start and end of each line
s dotAll . also matches line breaks
u unicode Treats emoji and other characters outside the basic range as one character

Regex cheat sheet

Pattern Meaning
. Any character except a line break
\d, \w, \s A digit, a word character (letter, digit, _), a space or tab
\D, \W, \S The opposite of each of the above
[abc], [^abc], [a-z] One of these, none of these, a range
*, +, ? 0 or more, 1 or more, 0 or 1
{3}, {2,5}, {2,} Exactly 3, 2 to 5, 2 or more
^, $, \b Start, end, word boundary
(abc), (?:abc), (?<name>abc) Capture group, group without capture, named group
a|b a or b

The full cheat sheet, including lookahead and lazy quantifiers, is under the tester.

Regex in Python and Java

The patterns you test here work in most languages with small changes:

  • Python: use re.findall(r"\b[6-9]\d{9}\b", text). The r before the string keeps backslashes as they are. Named groups are written (?P<name>...).
  • Java: use Pattern.compile("\\b[6-9]\\d{9}\\b"). Every backslash must be doubled inside a Java string.
  • JavaScript: use /\b[6-9]\d{9}\b/g directly, as in this tester.

Practise with string problems

Many string problems can be solved with or without regex. Try check whether a string contains only digits with the pattern ^\d+$, then solve it again with a loop. Remove all white spaces from a string is a one-liner with \s+ and replace.

Pro tip: Build a pattern in small steps. Start with the part you are sure about, check the highlights, then add one piece at a time. It is much easier than debugging a long pattern written in one go.

Frequently asked questions

What is a regular expression?
A regular expression, or regex, is a short pattern that describes text. For example \d{6} means six digits in a row, which matches an Indian PIN code. Programs use regex to search, check and replace text.
Which regex flavour does this tester use?
JavaScript regular expressions, run by your browser. Python, Java and most other languages share the same core syntax for character classes, quantifiers, groups and anchors, with small differences in advanced features.
Why does my pattern only find the first match?
Turn on the g (global) flag. Without it, JavaScript stops after the first match.
Why did the tester say matching was stopped?
Some patterns, such as (a+)+$, can take a very long time on text that almost matches, because the engine tries a huge number of combinations. The tester stops after 1.5 seconds so your browser does not freeze. Rewrite the pattern without nested repeats.
Is my text sent anywhere?
No. Matching runs in your browser, so you can safely test patterns on private text.

Try another tool

See all free tools
Chat with us