Regex Tester
. Any character except newline\d Any digit [0-9]\D Any non-digit [^0-9]\w Any word character [a-zA-Z0-9_]\W Any non-word character\s Any whitespace character\S Any non-whitespace character[abc] Match any character in the set[^abc] Match any character not in the set[a-z] Match a character in the range* Zero or more+ One or more? Zero or one (optional){n} Exactly n times{n,} n or more times{n,m} Between n and m times*? Zero or more (lazy)+? One or more (lazy)^ Start of string$ End of string\b Word boundary\B Non-word boundary(abc) Capturing group(?:abc) Non-capturing group(?<name>abc) Named capturing group\1 Backreference to group 1a|b Match a or b(?=abc) Positive lookahead(?!abc) Negative lookahead(?<=abc) Positive lookbehind(?<!abc) Negative lookbehindHow to Use
Enter a regex pattern and flags (g for global, i for case-insensitive, m for multiline, s for dotAll, u for unicode). Type test text below to see matches highlighted in real time, including capture groups and match positions. Switch to the Replace tab for substitution, or scroll down for pattern explanation, code snippets, and a quick reference.
Regular Expression Flags
g (global) finds all matches, not just the first. i (case-insensitive) ignores letter case. m (multiline) makes ^ and $ match line boundaries. s (dotAll) makes . match newlines. u (unicode) enables full Unicode matching. d (hasIndices) provides start/end indices for capture groups.
Common Use Cases
- Form validation — email addresses, phone numbers, postal codes, and other input checks
- Log parsing — extracting error messages, IP addresses, and timestamps
- Text replacement — normalizing whitespace, unifying half/full-width characters, batch formatting
- Scraping — pulling patterns out of HTML (use a real parser for complex structures, regex only for simple cases)
- Find and refactor — flexible pattern matching across editor project-wide search
Common Pitfalls
- Catastrophic backtracking — nested quantifiers like `(a+)+` can take exponential time on certain inputs, causing ReDoS (regex denial of service)
- Greedy vs lazy matching — `.*` is greedy (as long as possible) by default; `.*?` is lazy. Critical when extracting HTML tags
- Locale and Unicode — `\w` matches only ASCII letters/digits/underscore, not Japanese or emoji. Use the `u` flag and `\p{...}` properties for Unicode
- Dialect differences — JavaScript, Python, PCRE, and Java differ on features and syntax (lookbehind support, recursion, conditionals)
- Anchor misuse — without the `m` flag, `^` and `$` match only the start/end of the whole string, not each line
Privacy
All regex evaluation happens entirely in your browser using JavaScript's built-in RegExp engine. No patterns or test strings are sent to a server, stored, or logged.