Regex Tester: Validate & Debug Your Regular Expressions
$1 or $<name> for a captured group and $& for the whole matchReplace result
Pattern explanation
Enter a pattern above to see a plain-English breakdown of each token.
Regex Tester Tool
The Regex Tester is a real-time regular expression testing and debugging tool. Enter a regex pattern and a test string to see matches highlighted instantly as you type. It supports JavaScript regex syntax with flags such as global, case-insensitive, and multiline, and displays captured groups for each match. Type in the Replace With field to preview the text after substitution, using $1, $<name>, and $& as in JavaScript's replace(). All processing runs entirely in your browser, so no data is sent to any server.
How does our Regex Tester Tool Work?
Our Regex Tester Tool simplifies the process of working with regular expressions. Input your regex pattern and test string, and watch as the tool highlights matches instantly. Whether you're debugging complex patterns or learning the basics, our Regex Tester Tool is designed to make your regex experience smooth and efficient.
How to use:
- Enter your regular expression pattern in the provided field.
- Type or paste the text you want to test against.
- The tool will automatically highlight all matches and display match groups.
- Use regex flags (such as
g,i,m) to modify the search behavior.
Our tool also provides instant feedback on invalid patterns, making it easy to learn and experiment with regex syntax.
What is a regular expression?
A regular expression (regex or regexp for short) is a special text string for describing a search pattern. You can think of regular expressions as wildcards on steroids. You are probably familiar with wildcard notations such as *.txt to find all text files in a file manager. The regex equivalent is .*\.txt$.
Regular expressions were first developed in the 1950s by mathematician Stephen Cole Kleene and have since become a standard feature in most programming languages and text processing tools.
What can I use a regular expression for?
Regular expressions are widely used in programming languages, text editors, and command-line tools to search and manipulate text. You can use regular expressions to:
- Validate input (e.g., email addresses, phone numbers, postal codes)
- Search for patterns in text (e.g., finding all URLs in a document)
- Extract specific data from strings (e.g., capturing dates or numbers)
- Replace or reformat text (e.g., changing date formats) using a tool like the text replacer
- Split text into arrays based on patterns
They are a flexible way to work with text data and can save you a lot of time and effort when working with complex patterns.
What are the rules of regular expressions?
Regular expressions match various patterns in text. Here are some of the basic rules:
- 1. Anchors
- ^ and $ are used to match the start and end of a line, respectively.
- 2. Quantifiers
- * means zero or more, + means one or more, and ? means zero or one.
- 3. Character classes
- [abc] matches a or b or c, [a-z] matches any letter from a to z, and [^0-9] matches anything except a digit.
- 4. Grouping and capturing
- ( ) is used to group and capture matched text.
- 5. Alternation
- | is used to match either a or b.
- 6. Escaping
- \ is used to escape special characters like ., *, and +.
Which type of regular expression does this work with?
It tests JavaScript regular expressions, using your browser's own RegExp engine, so it accepts exactly the syntax and flags that engine supports: g, i, m, s, u, y, d, and v (a flag your browser does not support is hidden). Other languages share most of the basics, such as character classes, quantifiers, and groups, but differ in the details: PHP and Python have features JavaScript lacks, such as possessive quantifiers and inline flags like (?i), and the replacement syntax differs too. A pattern that works here is not guaranteed to behave the same in PHP, Python, Ruby, or Java, so check it in that language before relying on it. If you are writing regex for a JavaScript project, the JavaScript formatter can help keep your code clean alongside your patterns.
Can I use this tool for learning regex?
Absolutely! The tool is designed for both beginners and advanced users. Experiment with different patterns and see instant results.
Does this tool support regex flags?
Yes. Tick any of the JavaScript flags under the pattern: g (global), i (case-insensitive), m (multiline), s (dotall), u (unicode), y (sticky), d (match indices, shown beside each match and group), and v (unicode sets). u and v cannot be used together, so ticking one clears the other. g is on when the page opens, so every match is found. You can also paste a pattern written as a JavaScript literal, such as /\d+/gi: the slashes are removed and its flags are ticked for you.
Is my data safe?
All processing is done in your browser. No data is sent to any server.
Regex cheat sheet: anchors and boundaries
| Token | Description | Example |
|---|---|---|
^ | Start of the string (or line with the m flag) | ^abc |
$ | End of the string (or line with the m flag) | abc$ |
\b | Word boundary | \bword\b |
\B | Non-word boundary | \Bing |
Regex cheat sheet: character classes and shorthands
| Token | Description | Example |
|---|---|---|
. | Any character except a newline | a.c |
[abc] | Any one of a, b, or c | [aeiou] |
[^abc] | Any character except a, b, or c | [^0-9] |
[a-z] | Any character in the range a to z | [a-zA-Z] |
\d / \D | Any digit / any non-digit | \d\d |
\w / \W | Any word character (a-z, A-Z, 0-9, _) / non-word character | \w+ |
\s / \S | Any whitespace / any non-whitespace character | a\sb |
Regex cheat sheet: quantifiers
| Token | Description | Example |
|---|---|---|
* | Zero or more times | ab* |
+ | One or more times | ab+ |
? | Optional (zero or one time) | colou?r |
{n} | Exactly n times | \d{4} |
{n,} | n or more times | \d{2,} |
{n,m} | Between n and m times | \d{2,4} |
*? | Lazy quantifier (as few as possible) | <.*?> |
Regex cheat sheet: groups, ranges, and alternation
| Token | Description | Example |
|---|---|---|
(abc) | Capturing group | (ab)+ |
(?:abc) | Non-capturing group | (?:ab)+ |
(?<name>abc) | Named capturing group | (?<year>\d{4}) |
a|b | Alternation: match a or b | cat|dog |
(?=abc) | Positive lookahead | \d(?=px) |
(?!abc) | Negative lookahead | \d(?!px) |
Regex cheat sheet: flags
| Flag | Description | Example |
|---|---|---|
g | Global: find all matches, not just the first | /a/g |
i | Ignore case: match letters regardless of case | /abc/i |
m | Multiline: ^ and $ match at line breaks | /^a/m |
s | Dotall: the dot . also matches newlines | /a.b/s |
u | Unicode: full Unicode matching | /\u{1F600}/u |
y | Sticky: match only from the current position | /a/y |
d | Indices: report where each match and group starts and ends | /(a)b/d |
v | Unicode sets: Unicode matching plus set operations in classes | /[\p{L}--[a-z]]/v |
Regex cheat sheet: common escapes
| Token | Description | Example |
|---|---|---|
\. | Literal dot | example\.com |
\\ | Literal backslash | C:\\path |
\n | Newline | line1\nline2 |
\t | Tab | a\tb |
\( \) | Literal parentheses | \(\d+\) |
\$ | Literal dollar sign | \$\d+ |
Last reviewed: October 2026