Regex Tester
Write a pattern, paste your text, and see every match highlighted in real time.
What does this Regex Tester do?
This tool lets you write a regular expression and immediately see how it matches against a block of text. Type a pattern, choose which flags to apply, and paste in a test string; every match is highlighted directly in the text, listed individually with its position, and summarized with a total and unique count. There is nothing to install and nothing is sent anywhere, since matching happens right in your browser as you type.
How to Use This Regex Tester?
- Enter your pattern. Type the regular expression into the pattern field between the two slashes, without the slashes themselves.
- Pick your flags. Toggle g, i, m, or s to control global matching, case sensitivity, multiline anchors, and dot behavior across line breaks.
- Paste your test string. Add the text you want to check into the test string box below the pattern.
- Read the live status. A status bar tells you instantly whether the pattern is valid, how many matches were found, or what went wrong if the pattern has an error.
- Review the highlighted preview. Every match is marked directly inside your original text so you can see exactly what was captured and where.
- Check the match list. Each match is numbered separately with its matched value and its start and end character position.
- Copy or clear. Use Copy Matches to grab every result as plain text, or Clear to reset the pattern and test string and start fresh.
Built-In Features
Live, Real-Time Matching
Matches update as you type in either the pattern or the test string, so you can see the effect of every small change immediately without clicking a separate run button.
Four Toggleable Flags
Switch global, case-insensitive, multiline, and dotall matching on or off with a single click, and see exactly how each one changes the results in real time.
Inline Highlighted Preview
Matches are marked directly inside your original test string, so you can read matched and unmatched text together instead of guessing from a separate list.
Numbered Match Details
Every match is listed on its own line with its matched value and the exact character range it occupies in the test string, making it easy to reference a specific result.
Clear Syntax Error Messages
If a pattern is invalid, the status bar shows the underlying error message instead of a blank result, so you know exactly what needs fixing.
One-Click Copy of Matches
Copy every match, along with its position, as plain text with a single click, ready to paste into a spreadsheet, ticket, or code comment.
Understanding the Regex Flags
Flags change how a pattern behaves without changing the pattern itself. This tool supports the four flags used most often when testing everyday expressions.
| Flag | Name | What It Changes |
|---|---|---|
| g | Global | Finds every match in the string instead of stopping after the first one |
| i | Case Insensitive | Treats uppercase and lowercase letters as identical |
| m | Multiline | Makes ^ and $ match the start and end of each line, not just the whole string |
| s | Dotall | Allows . to also match line break characters |
Leaving the g flag off shows only the first match found, which is useful when you only care whether a pattern matches at all rather than how many times it occurs.
Regex Syntax Cheat Sheet
If you are trying to remember what a particular symbol does, this quick reference covers the building blocks used in most patterns. Test any of them directly in the tool above to see how they behave against your own text.
| Symbol | Meaning |
|---|---|
| . | Matches any single character except a line break |
| \d \w \s | Digit, word character, and whitespace character |
| \D \W \S | The opposite of \d, \w, and \s |
| ^ $ | Start and end of the string, or of a line when the m flag is on |
| * + ? | Zero or more, one or more, and zero or one of the preceding item |
| {n,m} | Between n and m repetitions of the preceding item |
| […] | A character class, matching any one character listed inside |
| (…) | A capturing group used to isolate part of a match |
| (?:…) | A non-capturing group, grouped without being captured |
| \b | A word boundary, useful for matching whole words only |
Combining a few of these building blocks, such as \d{4}-\d{2}-\d{2} for a date, is usually enough to cover most everyday matching needs without reaching for a more complex expression.
How Match Highlighting and Details Work
Once a valid pattern is entered, the tool scans your test string and turns each result into three connected pieces of information shown together.
Position Tracking
Every match records the exact index in the string where it starts and ends. Those numbers appear next to each result, which is useful when you need to know where in a larger document a match actually sits.
Duplicate and Empty Handling
The results panel counts how many matches are unique versus repeated, and flags any zero-length match separately so patterns that can match an empty string do not clutter the preview unnecessarily.
Common Regex Patterns You Can Test Here
If you are looking for a starting pattern rather than writing one from scratch, these are some of the most frequently needed expressions. Paste any of them into the pattern field and test them against your own sample text before using them in your project.
| Use Case | Example Pattern |
|---|---|
| Email address | [\w.-]+@[\w.-]+\.\w+ |
| Website URL | https?:\/\/[\w.-]+\.\w+[\w\/?=&#%-]* |
| Digits only | \d+ |
| Date (YYYY-MM-DD) | \d{4}-\d{2}-\d{2} |
| Hex color code | #[0-9a-fA-F]{6} |
| Extra whitespace | \s{2,} |
Once you have confirmed a pattern works, matched values can be copied straight out with Copy Matches, which is a quick way to pull structured values such as IDs or codes out of a larger block of text before dropping them into a JSON Formatter or another tool for further processing.
Using This as a JavaScript Regex Tester
Because the tool runs on the same regular expression engine built into every modern browser, it behaves exactly like the RegExp object used in JavaScript code. That makes it a practical place to test a pattern before dropping it into a script, since what matches here is what will match when the same pattern and flags run in a function, a form validator, or a Node.js project.
Same Matching Engine as Your Code
A pattern that matches correctly here will match the same way in a browser script or a Node.js file, since both rely on the same JavaScript regex engine.
Flags Map Directly to RegExp
The g, i, m, and s toggles correspond exactly to the flags passed into a JavaScript RegExp object, so there is nothing to translate before using the pattern in code.
Common Reasons to Use a Regex Tester
Validating Form Input
Check that a pattern correctly accepts valid emails, phone numbers, or usernames while rejecting malformed entries before adding it to a form.
Debugging an Existing Pattern
When a regex used in code is not matching as expected, testing it here in isolation, away from the surrounding program, quickly narrows down where it goes wrong.
Extracting Data From Text
Pull specific values, such as codes, IDs, or tags, out of logs, exported files, or pasted content by matching the pattern they follow quickly and accurately every time.
Learning How Regex Works
Change a pattern piece by piece and watch the highlighted preview update instantly, which is one of the fastest ways to understand what each part of an expression actually does.
Useful Tips
Turn Off Global to Test One Match
If you only need to confirm a pattern matches somewhere in the string, disabling the g flag returns just the first result, which keeps the preview simple.
Watch the Status Bar for Typos
Unbalanced brackets or an unescaped special character will show up immediately as an error message rather than a silent failure, so check it first if nothing highlights.
Use Real Sample Text
Test against a few realistic lines, including edge cases like extra spaces or mixed casing, rather than a single tidy example, so the pattern holds up once it is actually used.
Check the Unique Count
If the total matches and unique matches numbers differ, your text contains repeated values, which can be a quick and easy way to spot duplicates in a list.
Frequently Asked Questions
How do I test a regex pattern online?
Type your pattern into the pattern field, choose any flags you need, and paste your sample text into the test string box. Matches are highlighted and listed automatically as you type.
Is this regex tester free to use?
Yes. The tool is free, requires no account, and runs entirely in your browser.
What regex flavor does this tool use?
It uses JavaScript’s built-in regular expression engine, the same syntax used in browsers and Node.js applications.
What do the g, i, m, and s flags do?
g finds every match instead of just the first, i ignores letter case, m changes how ^ and $ behave across multiple lines, and s allows the dot character to match line breaks.
Why does my pattern show a syntax error?
This usually means a bracket, parenthesis, or special character is unbalanced or not escaped correctly. The status bar shows the exact error message returned by the engine to help you locate it.
Why are there no matches even though my pattern looks correct?
Check whether the global flag is needed, whether case sensitivity is affecting the result, and whether the test string actually contains the exact characters your pattern expects.
Can I see the exact position of each match?
Yes. Every match in the results list shows its start and end character index within the test string.
How many matches can this tool handle?
The tool processes up to 5,000 matches per test, which comfortably covers typical testing and debugging needs.
Can I copy all the matches at once?
Yes. The Copy Matches button copies every match, numbered and with its position, to your clipboard in one click.
Does an empty match count as a result?
Yes. Patterns that can match zero characters still appear in the results list, marked clearly as empty so they are not mistaken for missing data.
Is my text sent to a server when I use this tool?
No. Pattern matching runs locally in your browser using JavaScript, and your test string is never uploaded or stored.
Does this tool support named capture groups or lookaheads?
Since it relies on the standard JavaScript regex engine, any syntax that engine supports, including capture groups and lookaheads, can be used in the pattern field.
Does this tool work on mobile devices?
Yes. The layout adjusts to smaller screens and works the same way on phones, tablets, and desktop browsers.
