.Any character (except newline; with s flag, includes newline)[abc]Character set, matches a or b or c[^abc]Negated set, not a/b/c[a-z]Range, a to z\dDigit [0-9]\DNot a digit\wWord char [A-Za-z0-9_]\WNot a word char\sWhitespace (space/tab/newline)\SNot whitespace^Start of string (line start with m)$End of string (line end with m)\bWord boundary\BNot a word boundary*0 or more times+1 or more times?0 or 1 time{n}Exactly n times{n,}At least n times{n,m}Between n and m times*? +? ??Lazy (non-greedy) versions(abc)Capturing group(?:abc)Non-capturing group(?<name>abc)Named capturing group\1 \2Backreference to group n(?=abc)Positive lookahead(?!abc)Negative lookahead(?<=abc)Positive lookbehind(?<!abc)Negative lookbehinda|bAlternation, a or b\Escape special characters$&The whole match$1 $2The nth capture group$<name>Named capture group$`Text before the match$'Text after the match$$Literal $| Use case | Pattern | Description |
|---|
Using the regex tester is straightforward. Start by entering your pattern in the "Regular Expression" input field, then paste the text you want to test in the "Test Text" area. The tool highlights matches in real time and lists all capture groups in the results panel. If the results don't match expectations, adjust your pattern or toggle different flags.
This tool supports the full JavaScript regex syntax, including character classes (e.g., \d, \w, [a-z]), quantifiers (*, +, ?, {n,m}), grouping and capturing ((...)), and assertions ((?=...), (?<=...)). Enter a replacement template in the "Replace Text" box and click "Replace" to preview the result, with support for $1, $2 back-references.
The cheat sheet on the right provides common patterns like email, phone number, URL, and IP address, which can be clicked to auto-fill the regex field. Flags can be toggled via checkboxes: g for global match, i for case-insensitive, m for multiline, s for dotAll, and u for Unicode mode.
Regex testers are widely used in daily development and data processing. In front-end development, they are essential for form validation—checking email formats, phone numbers, and password strength. In back-end development, they help with log analysis and data extraction, pulling key information from massive log files. Data analysts use regex to extract structured data from unstructured text, such as links, prices, and dates from HTML source code.
During code refactoring, regex batch replacement can significantly boost productivity. For example, updating old API calls to a new version or standardizing code styles across a codebase. The real-time highlighting and group visualization make complex regex debugging intuitive, especially when you need to iterate on patterns frequently.
Regular expressions originate from formal language theory, introduced by mathematician Stephen Cole Kleene in the 1950s. Modern regex engines are divided into DFA (Deterministic Finite Automaton) and NFA (Non-deterministic Finite Automaton). JavaScript's RegExp is an NFA engine that supports backtracking and capture groups, offering powerful functionality but potentially lower performance with complex patterns.
Security-wise, be aware of ReDoS (Regular Expression Denial of Service): certain regex patterns with excessive backtracking (e.g., (a+)+) can cause catastrophic backtracking on specific inputs, freezing the application. In production, limit input length and implement timeouts. This tool is a pure frontend offline utility—all processing happens locally in your browser, so your data never leaves your device.
A regular expression (Regex) is a compact mini-language for describing string patterns. It uses a single concise string to match, find, and replace text that follows specific rules. Regex is widely used for form validation (email, phone), data cleaning, log analysis, URL routing, and code search-and-replace.
g global (find all matches, not just the first); i case-insensitive; m multiline (^ and $ match each line's start/end); s dotAll (. matches newlines); u Unicode (handles Unicode correctly, supports \p{...}); y sticky (must match consecutively from lastIndex). Combine freely, e.g. gi.
Common causes: 1) unbalanced parentheses or brackets, e.g. (abc missing ); 2) quantifiers in the wrong place, e.g. *+ at the start; 3) invalid backslash escapes; 4) using lookbehind (?<=) in an older browser; 5) an invalid pattern under the u flag. This tool shows the specific reason in the error message so you can fix it.
By default quantifiers are greedy and match as many characters as possible. <.*> matching <a><b> matches the whole thing. Adding ? makes it lazy: <.*?> matches only <a>. Supported: *?, +?, ??, {n,m}?.
No. This tool is pure frontend, with zero dependencies and zero network requests. All regex matching, highlighting, and replacement run locally in your browser. Your text never leaves your device, it works offline, and it is safe for sensitive data.
Special variables in the replacement string: $1–$9 reference capture groups; $& the whole match; $` text before; $' text after; $$ literal $. For example, regex (\d{4})-(\d{2})-(\d{2}) replaced with $3/$2/$1 turns 2024-01-15 into 15/01/2024. Named groups can be referenced with $<name>.