Regex
Pattern tester
Regex Tester
Test regular expressions against text in real-time.
How to use the Regex tool
Regular expressions (regex) are pattern-matching formulas used everywhere in system administration: validating input, extracting data from logs, and transforming text. This tester evaluates your pattern against sample text in real time, shows every match, and reports whether the pattern itself is valid — the fastest way to build and debug expressions before you use them in grep, sed, or a script.
- 1 Type a regex pattern, for example [a-z]+.
- 2 Toggle the flags: g (global), i (case-insensitive), m (multiline).
- 3 Enter a test string and watch matches highlight instantly, with a live count.
Example: Extract words: [a-z]+
Pattern: [a-z]+ Test: hello world 123
Matches: hello, world (2 matches) — digits are skipped
Regex FAQ
What do the regex flags g, i, and m do?
g finds every match instead of stopping at the first. i makes matching case-insensitive. m makes ^ and $ match at line boundaries rather than only at the start and end of the whole text.
Why does my pattern match more than expected?
Quantifiers like * and + are greedy by default: they match as much as possible. Add ? after them (e.g. .+?) for a lazy match, or anchor your pattern with ^ and $ to be precise.
How do I match special characters like dots?
Escape them with a backslash: \. matches a literal dot, while . alone matches any character. The same applies to +, *, ?, (, ), [, ], {, }, ^, $, and |.
Can I use this pattern in grep or sed?
Yes, with care: grep -E and sed -E use extended regular expressions which are close to what this tester runs. Some flavors (like PCRE in grep -P) support extra features such as lookahead.