How to use the regex tester
- Type your regular expression into the pattern field — for example
\b\w+@\w+\.\w+\bto find email-like text. - Toggle the flags you need: g for all matches, i for case-insensitive matching, m for multiline anchors, and s so the dot also matches newlines.
- Paste the text you want to search into the test string box.
- The results update as you type, showing whether it matches, how many matches were found, and each match with its character index.
Understanding the flags
| Flag | What it does |
|---|---|
| g | Global — finds every match in the string instead of stopping at the first. |
| i | Ignore case — makes letters match regardless of uppercase or lowercase. |
| m | Multiline — lets ^ and $ match at the start and end of each line. |
| s | DotAll — lets the dot (.) also match newline characters. |
Why test your regex here
Regular expressions are powerful but notoriously easy to get subtly wrong. A pattern that works on one test string can silently fail on another, and a misplaced quantifier can turn a quick match into catastrophic slowdown. Testing a pattern before you ship it into code — a form validator, a log parser, a find-and-replace rule — catches those problems early.
This tester builds the pattern with the JavaScript RegExp constructor inside a try/catch block. If your pattern has a syntax error, such as an unclosed group or a dangling backslash, it reports the error message directly instead of failing silently. That immediate feedback is the fastest way to learn regex or debug a pattern that is misbehaving.
A note on empty matches
Some patterns, like a*, can match an empty string at many positions. The tester detects empty matches and advances automatically so it never gets stuck in an infinite loop, while still listing every real match alongside its index in the original text.
