What is a regex tester?
A regex tester (regular expressions) is an interactive tool for writing, testing and debugging text search patterns. It lets you:
- See matches in real time as you type
- Inspect capture groups and their values
- Understand what each token in the pattern does
- Test against multiple test cases at once
- Detect syntax errors before using the regex in production
Anatomy of a Regular Expression
/ ^ [a-z] + \. (com|org) $ / g i m
| | | | | | | | | | |
| | | | | | | | | | ββ flags
| | | | | | | | | βββββ sticky (y)
| | | | | | | | βββββββ unicode (u)
| | | | | | | ββββββββββ dotAll (s)
| | | | | | βββββββββββββ multiline (m)
| | | | | | ββββββββββββββ case-insensitive (i)
| | | | | βββββββββββββββββββββ global (g)
| | | | | ββββββββββββββββββββββ capture group: "com" or "org"
| | | | βββββββββββββββββββββββββββββ literal character "."
| | | βββββββββββββββββββββββββββββββββ quantifier: 1 or more
| | ββββββββββββββββββββββββββββββββββββββ character class: lowercase letters
| βββββββββββββββββββββββββββββββββββββββββββ anchor: start of string
ββββββββββββββββββββββββββββββββββββββββββββββ delimiters (not part of pattern)Flags Available in JavaScript
| Flag | Name | Effect |
|---|---|---|
g |
Global | Finds all matches, not just the first |
i |
Case-insensitive | Ignores upper/lowercase |
m |
Multiline | ^ and $ match start/end of line, not just string |
s |
dotAll | . also matches newline (\n, \r) |
u |
Unicode | Treats pattern as Unicode code (needed for \p{...}, emojis, etc.) |
y |
Sticky | Searches only from lastIndex position (parsing performance) |
Common combination:
gim(global, case-insensitive, multiline) for general searches.
Included Presets
| Preset | Pattern | What it validates |
|---|---|---|
^[^\s@]+@[^\s@]+\.[^\s@]+$ |
Basic email format (simplified RFC 5322) | |
| URL | ^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$ |
HTTP/HTTPS URLs |
| IPv4 | `^((25[0-5] | 2[0-4][0-9] |
| DNI/NIE (ES) | ^[0-9]{8}[TRWAGMYFPDXBNJZSQVHLCKE]$ / ^[XYZ][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKE]$ |
Spanish documents |
| IBAN (ES) | ^ES[0-9]{22}$ |
Spanish IBAN (format only, no check digit validation) |
| Hex Color | `^#([0-9a-fA-F]{3} | [0-9a-fA-F]{6} |
| ISO Date | ^\d{4}-\d{2}-\d{2}$ |
YYYY-MM-DD (format only, doesnβt validate real days) |
| Phone (ES) | `^(+34 | 0034)?[679]\d{8}$` |
Token-by-Token Explainer
The explainer breaks down your pattern and describes each element:
| Type | Example | Generated Explanation |
|---|---|---|
| Anchor | ^ |
βStart of string (or line with m flag)β |
| Anchor | $ |
βEnd of string (or line with m flag)β |
| Class | [a-z] |
βCharacter class: any lowercase letter a-zβ |
| Negated class | [^0-9] |
βNegated class: any character EXCEPT digitsβ |
| Escape | \d |
βShortcut: digit (equivalent to [0-9])β |
| Escape | \. |
βLiteral character: dotβ |
| Quantifier | + |
βQuantifier: 1 or more times (greedy)β |
| Quantifier | *? |
βQuantifier: 0 or more times (non-greedy / lazy)β |
| Capture group | (abc) |
βCapture group #1: matches βabcβ literalβ |
| Non-capture group | (?:abc) |
βNon-capture group: groups without saving to $1β |
| Alternation | a|b |
βAlternation: matches βaβ OR βbββ |
| Lookahead | (?=abc) |
βPositive lookahead: asserts βabcβ follows without consumingβ |
| Lookbehind | (?<=abc) |
βPositive lookbehind: asserts βabcβ precedes without consumingβ |
| Unicode property | \p{L} |
βUnicode property: any letter in any languageβ |
Keyboard Shortcuts
| Action | Windows/Linux | Mac |
|---|---|---|
| Run test | Ctrl + Enter |
Cmd + Enter |
| Clear | Ctrl + Shift + X |
Cmd + Shift + X |
| Copy regex | Ctrl + Shift + C |
Cmd + Shift + C |
| Next preset | Ctrl + β |
Cmd + β |
| Previous preset | Ctrl + β |
Cmd + β |
Try the tester now
Write your regex, choose flags, paste the text and see matches instantly with detailed explanation.
Test your regex online with highlighting and token-by-token explanation.