How this regex tester works
A regular expression — regex for short — is a compact pattern that describes a set of strings. This tester takes the pattern you type and the flags you select, compiles them with the browser's built-in JavaScript engine, and runs the pattern over your test text. Every match is highlighted in place, counted, and listed with its starting position and any capture groups.
Patterns are built from literal characters and special tokens. Shorthand classes like \d, \w and \s stand for digits, word characters and whitespace; quantifiers like *, + and ? control how many times the preceding item repeats; and parentheses ( ) create capture groups that pull out parts of a match. If your pattern is invalid the tester shows the exact error so you can fix it as you type.
(\d{4})-(\d{2})-(\d{2}) with the test text 2026-06-02 produces one match, 2026-06-02, starting at index 0, with three capture groups: 2026, 06 and 02 — the year, month and day pulled out separately.Common regex tokens
| Token | Matches |
|---|---|
| \d | Any digit, 0–9 |
| \w | A word character: letter, digit or underscore |
| \s | Any whitespace: space, tab or newline |
| . | Any single character (except newline, unless the s flag is set) |
| * | Zero or more of the preceding item |
| + | One or more of the preceding item |
| ? | Zero or one of the preceding item (optional) |
| ^ | Start of the string (or line, with the m flag) |
| $ | End of the string (or line, with the m flag) |
| [ ] | A character set, e.g. [a-z] for any lowercase letter |
| ( ) | A capture group that remembers part of the match |
| | | Alternation: match the pattern on either side |
Reference note: this tool uses the JavaScript regular-expression syntax built into your browser. Some advanced features from other languages (such as lookbehind in older browsers) may behave differently, so test patterns against your own sample data.
Frequently asked questions
- How do I test a regular expression?
- Type your pattern into the pattern box and add some sample text in the test-string box. As you type, the tester compiles the expression and highlights every match, showing the count, each match position and any capture groups.
- What are regex flags (g, i, m)?
- Flags change how a pattern applies. g (global) finds all matches, i (ignore case) makes letters case-insensitive, and m (multiline) lets ^ and $ match the start and end of each line. The s (dotall) and u (unicode) flags are also supported here.
- How do I match digits, letters or whitespace?
- Use the shorthand classes:
\dmatches any digit,\wmatches a word character (letters, digits or underscore) and\smatches whitespace. Add a quantifier such as+to match one or more, like\d+for a run of digits. - What are capture groups?
- Parentheses
( )create a capture group that remembers the part of the match they surround. For example(\d{4})-(\d{2})captures a year and a month separately, which this tester lists next to each match. - How do I match an email or phone number?
- A simple email pattern is
\w+@\w+\.\w+and a basic phone pattern is\d{3}-\d{3}-\d{4}. These are starting points — real formats vary, so refine the pattern against your own sample data. - Is my text sent to a server?
- No. The tester runs entirely in your browser using the built-in JavaScript regex engine. Your pattern and test text never leave your device and are not sent to a server.