Cookies This site keeps only what it needs to work. There is no analytics and no advertising on it today, and nothing here follows you to other sites. Read the privacy policy

Choose what to allow
+92 312 8299940Free Quote
Free tool, nothing to install

Regex Tester
Match, Replace, Explain And Copy Code

This regex tester runs your regular expression on your text and lights up every match. Replace text, read the pattern in plain words, and copy it as code. We upload nothing.

  • FreePrice
  • 6Flags
  • NoneSign-up
  • NoneUploads

Regex Tester

Test a regular expression, see every match and copy it as code

Matches highlighted
Matches
0
Groups
0
Time
0
Every match
The matches and their groups
No.PositionMatchGroups
Replace
The pattern in plain words
    Use it in code

    Ready. Type a pattern.

    Your browser does all of the work here, in this tab. We upload nothing, store nothing and log nothing.
    The short version

    What A Regex Tester Does For You

    A regular expression is a small pattern that finds text. It can find an email, a date, a price or a tag. But one wrong character changes everything.

    A regex tester shows you the result as you type. First, type your pattern. Then paste a test text. Every match lights up at once, so you see what the pattern really catches.

    Also, it explains the pattern in plain words, one piece at a time. So you can learn a pattern that you found online, or check one you wrote.

    Everything runs in your browser. So your text never leaves your device.

    How The Regex Tester Works

    The tool gives your pattern to the regular expression engine of your browser. So the matches follow JavaScript rules exactly. Then it marks each match in your text and lists it in a table.

    Drawing of a pattern and a text on the left and an arrow to the same text with the matches highlighted on the right
    A pattern lights up its matches.

    Each match shows its position, its text and its groups.

    For more detail, see: MDN guide to regular expressions.

    Write A Pattern

    Type the pattern between the slashes. Do not type the slashes themselves. Then tick the flags you need.

    Regex tester with an email pattern, a test text with two email addresses highlighted and the match table below
    An email pattern with two matches.

    For example, the flag i ignores case, and the flag m lets ^ and $ work on every line.

    Flags Explained

    The flag g finds all matches, not just the first. The flag i ignores upper and lower case. The flag m makes ^ and $ match at each line.

    Then s lets the dot match a new line. The flag u turns on full Unicode. And y matches only at the exact spot where the last match ended.

    Read The Highlights

    Matches take turns between two colours, so two matches side by side stay easy to tell apart. An empty match has no colour, but it still shows in the table.

    Groups And Named Groups

    Round brackets make a group. The table lists the text of each group after the match.

    Also, a named group, such as (?\d{4}), shows under its name.

    Replace With A Pattern

    Type a replacement. Use $1 for the first group, $ for a named group, $& for the whole match and $$ for a dollar sign. Then the result shows below.

    Tick Replace only the first match to change just one.

    The Pattern In Plain Words

    The tool splits your pattern into pieces and names each one. For example, \d+ becomes a digit, one or more times. So you can learn from patterns written by others.

    Copy It As Code

    Pick JavaScript, Python, PHP, Java, C# or Go. The tool writes the pattern with the right quotes and the right flags. Then you copy it into your project.

    Ready Made Examples

    The example list holds patterns for emails, web addresses, dates, IPv4 addresses, hex colours, phone numbers, HTML tag pairs and extra spaces. Pick one, and the pattern and a test text appear.

    Then change them to fit your case.

    Common Patterns Worth Knowing

    \d matches a digit and \w a word character. \s matches whitespace, and a dot matches almost anything.

    Add + for one or more, * for zero or more, and ? for optional. Then put ^ at the start and $ at the end to match a whole line.

    Greedy And Lazy

    By default a quantifier takes as much as it can. Add a question mark after it to take as little as it can.

    So grabs a whole line of tags, while grabs one tag at a time.

    Look Ahead And Look Behind

    A look ahead checks what comes next without taking it. For example, \d+(?= dollars) finds numbers before the word dollars.

    Then a look behind checks what came before. Modern browsers support both.

    Slow Patterns

    Some patterns can take very long on some text. Nested quantifiers such as (a+)+ are the usual cause. The tool shows how long your pattern took, and it warns when that time is high.

    If the page freezes, simplify the pattern.

    Limits

    The tool reads up to 200,000 characters of test text and lists up to 2,000 matches. The table shows the first 200.

    Safe By Design

    First, the tool works in your browser. It sends nothing, and it stores nothing. So your text stays yours.

    How it works

    Using The Tester, Step By Step

    Four steps take you from a pattern to code.

    • 1

      Type a pattern

      Write it between the slashes, or start from an example.

    • 2

      Paste your text

      Every match lights up as you type.

    • 3

      Check the details

      Read the match table, the groups and the plain words.

    • 4

      Copy what you need

      Copy the matches, the replaced text or the code.

    Why this one

    What This Regex Tester Does Differently

    It shows, explains and exports your pattern, and it keeps your text private.

    • Live highlights

      Every match lights up as you type, in two alternating colours.

    • Plain words

      Each piece of the pattern gets a short explanation.

    • Groups and replace

      See each group, then replace with $1, $ or $&.

    • Six languages

      Copy the pattern as JavaScript, Python, PHP, Java, C# or Go.

    • Ready made examples

      Start from email, URL, date, IP, colour and more.

    • Nothing leaves your tab

      Your browser runs the pattern. We never see your text.

    Good habits

    Habits For Writing Good Regular Expressions

    A few habits keep your patterns safe and clear.

    • Start small. Match one piece first, then grow the pattern step by step.
    • Test with bad input. Add text that should not match, and check that it stays quiet.
    • Escape special characters. Put a backslash before a dot, a plus, a bracket or a dollar sign.
    • Anchor when you can. Use ^ and $ so the pattern checks the whole value.
    • Prefer lazy quantifiers. They stop at the first closing mark, not the last.
    • Name your groups. A name tells the next reader what a group holds.
    • Avoid nested quantifiers. Patterns such as (a+)+ can freeze on long text.
    • Mind the engine. Languages differ a little, so test where the code will run.
    • Comment hard patterns. Write a line that says what the pattern is for.
    • Do not parse HTML. Use a parser for markup, and keep regex for simple jobs.
    • Keep private text out. Use sample data instead of real names and emails.
    Worth avoiding

    Common Regex Mistakes This Tool Helps You Avoid

    Each of these quietly breaks a pattern.

    • Forgetting the g flag

      Without g, only the first match counts.

    • An unescaped dot

      A dot matches any character, so escape it to match a real dot.

    • Greedy surprises

      A greedy .* can swallow far more text than you meant.

    • Missing anchors

      Without ^ and $, a pattern can match inside a longer value.

    • Catastrophic backtracking

      Nested quantifiers can take seconds, or longer, on short text.

    • Wrong slashes in code

      Each language quotes a pattern in its own way. Copy the code from the tool.

    Questions

    Regex Tester Questions People Ask

    Is this regex tester free?

    Yes. It costs nothing, needs no account and has no limits. It runs in your browser, so we have no server cost to pass on.

    Does my text leave my device?

    No. Your browser runs the pattern. Nothing reaches this site, and we keep nothing.

    What is a regular expression?

    It is a pattern that describes text. You use it to find, check or change text in code, editors and tools.

    How do I test a regex?

    Type the pattern in the box, paste your text, and read the highlights. Change the pattern until the right parts light up.

    Which regex flavour does it use?

    The JavaScript flavour of your browser. It is close to PCRE, but a few features differ, so test where the code will run.

    What do the flags mean?

    g finds all matches, i ignores case, m makes ^ and $ work per line, s lets the dot match a new line, u turns on Unicode and y matches at one spot only.

    Why do I only get one match?

    The g flag is off. Tick Find all (g) to list every match.

    Why do I get no matches?

    The pattern may not fit the text, a special character may need an escape, or the case may differ. Tick Ignore case to check.

    How do I match a digit?

    Use \d for one digit and \d+ for a run of digits. For exactly four digits, use \d{4}.

    How do I match an email address?

    Pick the Email address example. It finds the usual forms. For strict checks, send a confirmation mail.

    What is a capture group?

    A part of the pattern in round brackets. The tool lists the text each group caught, in the Groups column.

    What is a named group?

    A group with a name, written (?<name>...). You can read it by name in code and in the replacement as $<name>.

    How do I replace text?

    Type the replacement in the Replace with box. Use $1 for a group and $& for the whole match.

    What is a look ahead?

    A check on what follows, without taking it. For example, \d+(?= dollars) matches the number but not the word.

    What is the difference between greedy and lazy?

    A greedy quantifier takes as much as it can. A lazy one, with a question mark after it, takes as little as it can.

    How do I match across several lines?

    Tick Dot matches new line (s) so the dot crosses line breaks, and Multiline (m) so ^ and $ work on each line.

    How do I escape a special character?

    Put a backslash before it, such as \. for a dot. The String escape tool can do this for a whole phrase.

    Can I copy the pattern as code?

    Yes. Pick JavaScript, Python, PHP, Java, C# or Go in the Language box, and press Copy the code.

    Why is my pattern slow?

    Nested quantifiers, such as (a+)+, can take a very long time on some text. The tool shows the time and warns you.

    How much text can I test?

    Up to 200,000 characters. The tool lists up to 2,000 matches, and the table shows the first 200.

    Can I test a regex for another language?

    You can test the logic here, then copy the code for the language you need. Very advanced features may differ, so run a final check there.

    Does it work on a phone?

    Yes. The panels stack and the tables scroll. So you can test a pattern on the go.

    More free tools

    Handy Companions For Text Work

    Testing is one step. These three tools help with the rest.

    Ready To Test A Pattern?

    Type a pattern, paste your text, and watch the matches light up. The tester is free, needs no account, and keeps every character on your device.