Write · Real‑time match · Syntax highlight · Capture groups · String replace
. any char\w word char\d digit\s whitespace
* 0++ 1+? 0 or 1{n,m} n to m
^ start of line$ end of line\b word boundary(?=) lookahead
[abc] a/b/c[^abc] not a/b/c(a|b) a or b() capture group
Regular expressions are the Swiss Army knife for text processing – used for data validation, text extraction, string replacement, and syntax parsing. ng.cc's online regex tester provides a real‑time environment for writing, matching, and replacing, with support for g/i/m/s flags, match positions, capture groups, and replacement preview. Includes 6 common templates and a quick reference cheat sheet. 100% client‑side, zero data upload.
Type and see matches instantly: match positions, context preview, capture groups. Toggle global/ignore case/multiline flags.
Automatically detect capture groups and display each group's content. Easily debug complex regex.
Supports $& (full match), $1-$9 (capture groups). Live preview, one‑click copy result.
Email, phone, IP, URL, Chinese characters, date/time. One‑click load, get started instantly.
*? +? ?? {n,m}? By default quantifiers are greedy (match as much as possible). Add ? to make them lazy. Example: <div>.*?</div> matches the shortest div tag.
(?=pattern) matches a position followed by pattern, without consuming characters. Example: \d+(?=px) matches digits that are followed by "px".
(?<=pattern) matches a position preceded by pattern. Example: (?<=\$)\d+ matches digits after a dollar sign.
\A, \Z, \G, recursive matching, balancing groups, etc. However, for everyday validation, extraction, and replacement, JS regex is more than enough. For testing PCRE patterns, use a dedicated tool.
(a+)+b) can cause catastrophic backtracking on certain inputs, making the browser hang. This tool includes protection against long runs, but we recommend: 1) avoid nested quantifiers; 2) use non‑greedy quantifiers; 3) break complex regex into steps. If it freezes, just refresh the page.
[\u4e00-\u9fa5] for a single Chinese character, [\u4e00-\u9fa5]+ for multiple. Note: this covers common Han characters but not rare extensions. For full Han support, use \p{Script=Han} (requires u flag).
(?=), negative lookahead (?!), positive lookbehind (?<=), negative lookbehind (?<!). Example: \w+(?=@) matches the username part of an email.
This regex tester is part of the ng.cc text‑processing toolkit. You might also like:
⚡ All processing happens locally – your regex and data never leave your browser.