dev utility
Grep-Style Regex Tester
Test JavaScript regular expressions against local text, with grep line mode, capture groups and highlighted matches.
Grep-style regex tester
Test a JavaScript regular expression against local text. See matches, capture groups and whole matching lines without uploading anything.
JavaScript syntax; pattern limited to 500 characters.
Up to 1 MiB. Your test text is not sent to a server.
Matches
Captured matches
Regex dialects and grep pitfalls
This tester uses the JavaScript RegExp engine. A pattern that works here may fail in grep, ripgrep, PCRE or another language—and vice versa. Match the engine to the one your production command actually uses.
Major dialect differences
- JavaScript (this page)
- Supports lookahead, lookbehind (modern browsers), named groups
(?<name>…), backreferences and lazy quantifiers. Flags are separate (g i m s u y); Unicoded/wremain ASCII unless you useuwith Unicode property escapes. - PCRE / PCRE2 (
grep -P, PHP) - Supports lookaround, atomic/possessive quantifiers, recursion and branch-reset groups that JavaScript does not. Named groups use
(?<name>…)or(?'name'…); inline flags such as(?i)are common. Backtracking semantics can differ on edge cases. - GNU grep default (BRE)
- Basic regular expressions:
(),+,?and{}need escaping to be operators. Usegrep -Efor ERE, orgrep -Pfor PCRE. grep is line-oriented by default and treats the pattern as a match anywhere in a line unless you add anchors. - GNU grep ERE (
grep -E) - Extended syntax makes
+ ? | () {}operators without backslashes. There are no lookarounds or non-greedy quantifiers in POSIX ERE. Use-oto print only matches,-ifor case-insensitive matching and-vto invert. - ripgrep / Rust regex
- Fast and Unicode-aware by default, but deliberately does not support lookaround or backreferences. Use
rg -P(PCRE2 build) when those features are truly needed. ripgrep searches recursively by default and respects.gitignoreunless told otherwise. - POSIX character classes
[[:digit:]],[[:alpha:]]and similar are POSIX/grep constructs. JavaScript does not understand them; used,p{L}with theuflag, or explicit ranges instead.
Common grep and regex traps
- grep prints lines, not matches. A line is reported if any part matches. Use
grep -oto print only the matched text, or this page's match list to inspect substrings. - Shell quoting changes the pattern. Double quotes let the shell expand
$, backticks and backslashes; single quotes are usually safer. Copy the exact pattern that reaches grep, not the shell-escaped form. - BRE versus ERE. In default
grep,a+may mean a literal plus; usegrep -E 'a+'or escape it asa+. Test both before putting a command in a script. - Dot does not match a newline. In JavaScript,
.stops at line breaks unless thesflag is set. grep is line-oriented, so a pattern spanning lines needs a tool that can read the whole file or-z/multiline handling. - Anchors and CRLF.
^and$are line anchors only with themflag in JavaScript. Windows CRLF files may leavebefore$; strip it or account for it. - Word boundaries are not universal. JavaScript
is ASCII-word based without Unicode property escapes; grep and ripgrep may use different definitions for accented or non-Latin words. - Unicode characters are not one byte. Byte-oriented tools and Unicode-aware tools can disagree about
w, case folding and positions. Validate with the same locale and encoding as production. - Catastrophic backtracking. Nested quantifiers such as
(a+)+$can hang a browser or the command line on adversarial input. Keep patterns bounded and test untrusted input separately. - Stateful
gandyflags. In JavaScript, repeatedRegExp.test()calls withgadvancelastIndex; reset it or use a fresh expression. This tester manages that loop for you, but your own code must too. - Named-group syntax differs.
(?<name>…)is shared by JavaScript and PCRE, but older PCRE may require(?'name'…), and some engines use(?P<name>…)(Python).
The safest workflow is to test the exact engine and flags you will use in production, including the target locale, file encoding and shell quoting. This page is a JavaScript-expression tester, not a GNU grep or PCRE emulator.
How it works
A local regex workbench for logs, text and data. Choose match-anywhere or grep matching-lines mode, set the common flags, inspect capture groups and copy matching lines. The expression and text never leave the browser.
Limits
- Uses JavaScript regular-expression syntax, not PCRE, GNU grep or ripgrep extensions.
- Patterns and text are capped to keep the page responsive; pathological backtracking can still be slow.
- Matches are capped at 1,000 results.
- No file upload: paste or type text.
Questions
Is this PCRE or GNU grep?
No. It uses the browser JavaScript RegExp engine. Lookahead and named groups are supported, but PCRE/ripgrep-only syntax is not.
Does it support grep-style output?
Yes. Grep mode tests each line and shows only lines containing a match, with line numbers and highlighted hits.
Is the tested text uploaded?
No. Matching, highlighting and export all happen in this tab.
Privacy
Usage measurement is off for this tool. This page makes no analytics request. Your input is not sent to a server.