A regular expression (regex) is a compact pattern language for finding, validating and transforming text — one line can validate an email address, pull every phone number out of a document, or reformat a spreadsheet column. The catch is that a single misplaced bracket changes the meaning entirely. A regex tester removes that pain: type your pattern, paste your sample text, and see every match highlighted instantly.
This tester runs entirely in your browser on the JavaScript regex engine, the same engine behind browser form validation and Node.js. toggle the classic flags — g (all matches), i (ignore case), m (line anchors), s (dot matches newlines), u (Unicode) — and each match card shows the character index plus every capture group, so you can see exactly what $1 and $& will hold in your code. Nothing is uploaded or stored, so testing against proprietary data is safe, and the optional replacement preview lets you try find-and-replace logic before touching real files.
How to use the Regex Tester
- \n
- Type your pattern - no surrounding slashes needed. \n
- Toggle flags - leave global on to see all matches. \n
- Paste your test text - matches highlight as you type. \n
- Inspect each match - index plus every capture group. \n
- Preview replacements - optionally use
$1,$2,$&. \n
Quick pattern cheat sheet
| Token | Matches | Token | Matches |
|---|---|---|---|
| \d | any digit | + | one or more |
| \w | word character | ? | optional |
| . | any character | (abc) | capture group |
| ^ … $ | start / end | [a-z] | character range |
Why live testing beats trial and error
Most regex bugs are silent: a greedy .* swallows too much, an unescaped dot matches things you never intended, and a missing flag breaks a pattern that works in your head but not on real input. Highlighting matches as you type makes debugging visual - and testing with the flags you will ship matters, because case-sensitivity mistakes are the most common reason validations fail.
Frequently asked questions
How do I test a regular expression online?
Type your pattern, paste sample text, and matches highlight live. Toggle flags and check each match card for its index and capture groups.
What do the regex flags g, i, m, s and u do?
g finds all matches, i ignores case, m anchors ^ and $ to line boundaries, s lets the dot match newlines, u enables Unicode.
How do capture groups work?
Text in parentheses becomes a numbered group. Each match card shows group 1, group 2, and so on - exactly what your code receives.
Can I test a find-and-replace?
Yes - enter a replacement string with $1, $2 or $& and the live preview shows the transformed text.
Is my pattern or text sent to a server?
No. Everything runs locally in your browser; nothing is uploaded, logged or stored.
Runs on the JavaScript (ECMAScript) regex engine. Patterns that use lookbehind, named groups or possessive quantifiers from other flavors may behave differently here.