Tester Regex
Testa espressioni regolari JavaScript in tempo reale. Corrispondenze, gruppi di cattura e sostituzioni istantanee.
/
/
Inserisci un input sopra per vedere il risultato.
Inserisci un input sopra per vedere il risultato.
What is this for?
Regular expressions are dense and unforgiving. The way to write one that actually works is iteratively — pattern, sample text, see what matches, adjust. This tool gives you that loop in your browser using the JavaScript engine's native RegExp, plus capture-group inspection and a replacement preview. Patterns and inputs never leave the page.
When to use it
- Validating user input (email-shaped, phone-shaped, postcode-shaped) and seeing exactly which inputs pass and fail.
- Parsing log lines, extracting fields, building log filters.
- Designing find-and-replace patterns before running them across a real codebase.
- Debugging a regex you copied from Stack Overflow that doesn't work — paste it here, see what it actually matches.
Common patterns
\b\w+@\w+\.\w+\b— email-ish^\s*$— empty/whitespace-only line (withmflag)(?<year>\d{4})-(?<month>\d{2})— named capture groups(?:.*)— non-capturing group(?=foo)/(?!foo)— lookahead / negative lookahead
Common gotchas
- JavaScript ≠ PCRE. No
\K, no recursive patterns, lookbehind only since ES2018. Patterns from Perl, PHP, or Python often need adjustment. - Without
gflag you get the first match only. Addgfor "find all"; combine withmif anchors should match per-line. - Greedy vs lazy.
.*grabs as much as possible;.*?grabs as little. The difference between matching<b>hi</b> and <i>there</i>as one block vs two. - Anchors at line vs string boundaries.
^and$match string ends by default; withmflag they match each line. - Replacement specials.
$&is the whole match;$1,$2, … are capture groups;$$is a literal$. Forgetting that is a common source of "why is my regex eating my dollars". - Don't parse HTML with regex for anything serious. The classic warning is true: nested tags, comments, and CDATA need a real parser. Regex is fine for one-off log scraping or controlled inputs.