Regex Tester

Regex Tester

Use this free regex tester to test regular expressions live — see matches, groups and replacements instantly, right in your browser.

Flags:

Matches: 0

Highlighted matches

Match list

    Replacement preview

    Privacy: everything in this regex tester runs in your browser. Your pattern and test text are never sent anywhere or stored.

    How to use the regex tester

    This regex tester lets you try out a regular expression against your own text and see the result straight away, with every match highlighted. It is made for beginners as well as developers, and everything runs in your browser, so nothing you type is sent anywhere.

    Step 1: Type your pattern in the regular expression field at the top of the regex tester. The pattern is already filled in with a simple example, so you can change it or clear it and start from nothing.

    Step 2: Tick the flags you need. The g flag is on by default, so the regex tester finds every match, not just the first one. The i flag ignores upper and lower case, m makes the start and end markers work on every line, s lets a dot match a new line, and u turns on full Unicode matching.

    Step 3: Type or paste your test text, and add a replacement text if you want to see what the result would look like with the matches replaced. The highlighted text, the match list with capture groups, the match count and the replacement preview all update live on every keystroke.

    Worked examples

    Try the pattern \d+ with the g flag, on the text Order 123 and 456. The pattern \d+ means one or more digits, so it matches 123 and then 456, and the regex tester shows a match count of 2, with each match and its index in the list. That is the simplest useful pattern: it finds every number in a piece of text, whatever the number is.

    Now try the email pattern \b\w+@\w+\.\w+\b with the g flag, on the text Contact me at test@example.com. This pattern looks for a word, then the @ sign, then another word, a dot and a final word, with word boundaries at each end. It matches test@example.com as one match. Email addresses in real life can be more complicated than this, with dots, plus signs and longer endings, but this pattern is a good starting point for finding email-like text.

    Replacement is just as quick. With the pattern cat, the g flag and the replacement dog, the text the cat sat becomes the dog sat in the replacement preview. Try it with a longer sentence and you will see every cat change to dog, while the rest of the text stays the same.

    Common patterns

    A few building blocks cover most everyday patterns. The pattern \d+ matches one or more digits, so it finds numbers. The pattern \w+ matches one or more word characters, which are letters, digits and the underscore, so it finds words. The pattern ^ matches the start of the text, or the start of a line when the m flag is on, and the pattern $ matches the end of the text, or the end of a line with the m flag. The email shape above is built from those blocks: word characters, an @ sign, more word characters, a dot and a final word.

    Round brackets make a capture group, which is a part of the match you can use on its own. For example, the pattern (\d+)-(\d+) on the text 2026-11-05 matches the whole date, and its two groups are 2026 and 11, so you can pull the year and the month out separately. Square brackets make a character set: [aeiou] matches any single vowel, and [0-9] matches any single digit. A dot matches any single character except a new line, unless the s flag is on, and a star means zero or more of the thing before it, while a plus means one or more.

    If your pattern does not match, check the simple things first: spelling, upper and lower case, and whether the flag you need is ticked. A pattern that works on one line may need the m flag to work on many lines, and a pattern that should match a literal dot needs a backslash before the dot, because a plain dot means any character. If the pattern itself is not valid, this regex tester will say so plainly, with the message That pattern isn't valid — check the brackets and slashes, and it will never crash or show a blank page.

    Frequently asked questions

    What is a regular expression?

    A regular expression, often called a regex, is a short pattern that describes a shape of text. You use it to find, check or replace text that follows that shape, such as numbers, email addresses or dates, instead of searching for one exact word.

    What do the flags (g, i, m, s, u) do?

    The g flag finds all matches, not just the first. The i flag ignores upper and lower case. The m flag makes the start and end markers work on every line. The s flag lets a dot match a new line. The u flag turns on full Unicode matching.

    Why does my pattern show no matches?

    Check the spelling and the case of your pattern, and check that the flag you need is ticked. A common cause is a missing backslash before a dot or another special character, or a pattern that only matches at the start or end of a line without the m flag.

    What are capture groups?

    Capture groups are the parts of a pattern inside round brackets. Each group captures the text that matched that part, so you can see it and use it separately. This regex tester lists the groups for every match.

    Is my text stored or sent anywhere?

    No. Everything in this regex tester runs in your browser. Your pattern and your test text are never sent anywhere and are never stored.

    Scroll to Top