Regex-tester
Regex-tester
Test reguliere expressies met realtime matching, vlagbediening, opvanggroepen, benoemde groepen en direct vervangingsvoorbeeld. Inclusief prestatie-risicodetectie en time-outbeveiliging — ideaal voor patroonvalidatie, tekstextractie en batchvervanging.
Snelstart
Veelvoorkomende scenario's
Extraheer ID's, e-mails, datums of aangepaste tokens uit logboeken en tekst.
Valideer de invoerformaten van gebruikers voordat deze in code worden geïntegreerd.
Vervang inhoud batchgewijs met behulp van vastleggroepen en benoemde groepen.
Gebruiksadvies
Beperkingen & compatibiliteit
Privacy & veiligheid
Veelgestelde vragen
A regular expression (regex) is a pattern language for describing text structures. Think of it as an "advanced search" — instead of searching for a fixed word, you search for everything matching a rule.\n\nFor example, \\d{4}-\\d{2}-\\d{2} matches all dates in YYYY-MM-DD format, and [\\w.]+@[\\w.]+ matches email addresses. Regex is widely used for: text search & extraction (finding error codes in logs), format validation (checking phone numbers), and batch replacement (converting date formats).\n\nAlmost every programming language (JavaScript, Python, Java, Go, etc.) and many tools (VS Code, grep, sed) support regex with mostly similar syntax. This tool uses the JavaScript RegExp engine for quick online testing and learning.
JavaScript regex returns only the first match by default — this is a language specification behavior, not a tool limitation. Click the g button in the flags bar to enable global search and see all matches.\n\nNote the interaction between g and y: g scans the entire text from start to end, while y (sticky) requires each match to start exactly where the previous one ended — if there are gap characters between matches, y stops at the first gap. Usually just enabling g without y is sufficient.
There are four common causes:\n\n1. Unmatched brackets: every ( must have a matching ), every [ must have a matching ]. IDEs may auto-complete these, but this tool requires manual pairing.\n2. Misplaced quantifiers: quantifiers (*, +, ?, {n}) must follow a quantifiable element. Combinations like *+ or ?* are illegal, unless the first quantifier is ? for lazy modification (like *?).\n3. Incomplete escapes: a lone \\ at the end is illegal — it must escape a specific character (like \\d, \\n, \\\\).\n4. Unicode properties need u flag: \\p{L}, \\p{Script=Han} and similar Unicode property escapes throw errors without the u flag enabled. Click the u button to enable it.
These are replacement reference tokens defined by JavaScript's String.prototype.replace():\n\n- $1, $2, ..., $99: reference the content captured by the nth capture group (...)\n- $&: the entire matched text\n- $`: the text before the match\n- $': the text after the match\n- ${name}: the content captured by named group (?<name>...)\n\nFor example, pattern (\\w+)\\s(\\w+) matching "hello world" with replacement $2-$1 produces "world-hello". To include a literal $ in the replacement, use $$ to escape it.
Timeouts are almost always caused by "catastrophic backtracking". When the regex engine encounters nested quantifiers (like (a+)+b) or overlapping optional paths, it backtracks through an exponential number of combinations, causing match time to explode.\n\nTypical dangerous patterns: (a+)+, (.*?)*, (.+)+$ etc. Solutions:\n1. Replace . with precise character classes, e.g. [^\\s]+ instead of .+\n2. Avoid nested quantifiers — change (a+)+ to a+\n3. Reduce overlapping optional paths — change (a|ab)+ to a+b?\n\nAfter adjusting the pattern, click the "Retry" button in the match results area. The tool has a 4-second timeout protection and won't freeze your browser.
Different languages have regex engine differences in three main areas:\n\n1. Syntax support varies: JavaScript doesn't support PCRE recursive patterns (?R), conditional branches (?(cond)yes|no), or atomic groups (?>...). Python's re module also lacks these, but its regex module supports them. Java supports atomic groups but not recursion.\n2. Unicode handling differs: Python 3's re processes \\w, \\d as Unicode by default; JavaScript uses ASCII by default — you must enable the u flag manually. This means \\w won't match Chinese characters and \\b word boundaries don't apply between CJK characters.\n3. Newline semantics differ: Python's . doesn't match \\n by default (same as JavaScript), while Java's Pattern.DOTALL behaves the same as JavaScript's s flag.\n\nRecommendation: use this tool for quick logic verification, then do final confirmation with your target language's engine.