Regex Tester
Test a regular expression with highlighted matches and groups.
Highlighted matches
Matches will be highlighted here.
Cheatsheet
| Pattern | Meaning |
|---|---|
. | Any character except newline |
\d \w \s | Digit, word character, whitespace |
\D \W \S | Not a digit, word character, whitespace |
[abc] [^abc] [a-z] | Character class, negated class, range |
^ $ \b | Start, end, word boundary |
* + ? {n} {n,m} | Zero or more, one or more, optional, exact, range |
( ) (?: ) (?<name> ) | Capturing group, non-capturing group, named group |
| | Alternation (or) |
(?= ) (?! ) | Positive / negative lookahead |
Runs entirely in your browser. Nothing you paste or upload leaves your device.
How to use the regex tester
- Type your regular expression into the Pattern box.
- Type or paste the text to test.
- Press “Test” to see the matches highlighted, with the groups listed.
Regex tester example
Pattern \b03\d{2}-?\d{7}\b with the g flag matches Pakistani mobile numbers written as 0300-1234567 or 03001234567.
Common building blocks
- \d digit, \w word character, \s whitespace, . any character.
- + one or more, * zero or more, ? optional, {3} exactly three.
- ^ start, $ end, ( ) capture group, | or.
Tips for using the regex tester
- Test against examples that should not match, too.
- Escape special characters (. * + ? ( ) [ ] { } \ | ^ $) with a backslash to match them literally.
Regex tester: common questions
- What is a regular expression?
- A pattern for finding text — for example, \d+ finds numbers and [A-Z]+ finds capital letters.
- What do the flags do?
- g finds every match instead of the first, i ignores upper and lower case, m treats each line separately, s lets . match new lines, u turns on Unicode, and y anchors the match at one position.
- Why does my pattern show no matches?
- Check for a missing escape (such as \. for a real dot) or a flag you need. The sample pattern is a working example to start from.
- Is my pattern or text uploaded?
- No. Testing runs in your browser.
- Which regex flavour is used?
- JavaScript (ECMAScript), the same as in browsers and Node.js. Most simple patterns work the same in Python, PHP and Java.