Regex Tester
Test a JavaScript-compatible regular expression against sample text.
Trying a regular expression in the browser
The box runs a JavaScript regular expression against the text you paste. JavaScript regex is close to what many people mean by a regex, and it is not identical to POSIX BRE, to grep -E, or to Python. Lookahead and lookbehind exist here. POSIX character classes such as [:digit:] do not, unless you are in a flavor that supports them. A pattern that works in this page can still fail in sed.
Type the pattern without slashes. Put the sample in the text area. A match is highlighted. Use this to check an anchor before you put the expression in a log filter or a fail2ban regex. Anchors matter: a pattern of error matches the middle of a word, and ^error matches only at the start of a line, depending on the multiline flag. If the tool exposes flags, dot does not match a newline unless you set that flag.
Greedy quantifiers take as much as they can and give back only to let the rest of the pattern succeed. .* in the middle of a line will run to the end and then retreat. If you wanted the smallest match, the quantifier is *? in JavaScript. The tester shows what this engine did, not what you hoped.
It does not search a file, and it does not know grep's -P or pcre. Catastrophic backtracking is still possible. A nested quantifier on a long line can hang the tab. Keep the sample short.
