How to use it
- Type a pattern.
- Paste your text.
- See every match highlighted.
Why use it
- Test patterns without running code.
- See every match and capture group.
- Toggle flags to refine results.
- Catch mistakes before they ship.
- Instant with no install.
What is a regular expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. It is used to match, capture, and extract text in programming languages, text editors, command-line tools, and data pipelines. Once you learn regex, patterns like validating an email, extracting URLs, or finding all number ranges become a single line of code.
Common building blocks
| Pattern | Meaning | Example |
|---|---|---|
\d | Any digit | a\db matches "a1b" |
\w | Any word character (letter, digit, _) | \w+ matches a word |
\s | Any whitespace | a\sb matches "a b" |
. | Any single character | c.t matches "cat" |
* | Zero or more of the previous | ab*c matches "ac" and "abbc" |
+ | One or more of the previous | ab+c matches "abbc" but not "ac" |
^ | Start of string / start of line (with m) | ^abc matches "abc..." |
$ | End of string / end of line (with m) | xyz$ matches "...xyz" |
(...) | Capture group | (\d+)px captures the number |
[a-z] | Any character in a range | [a-z0-9] matches a lowercase letter or digit |
Regex flags explained
- g (global): find all matches instead of stopping at the first one.
- i (ignore case): match letters regardless of case.
- m (multiline): make ^ and $ match the start/end of each line.
- s (dot all): make the dot match newline characters too.
Combining these flags is where regex gets powerful. For example, pattern /is/gifinds every occurrence of "is" or "IS" across all lines of a document. Use this tester to see exactly how your pattern and flags behave before you commit them to code.