Live regex match / replace with highlights, group capture and a template library.

Switch tool
//g
Test text
0 chars · 0 lines
Highlighted preview
Matches
No matches yet — enter pattern and text.

How to use

Purpose

Online regex tester supporting JavaScript / PCRE / Python / Java / Go dialects with real-time match highlighting, capture groups, named groups. Provides g/i/m/s/u/y flag combinations (global, ignore-case, multiline, dotAll, Unicode, sticky), visual capture group structure, common regex library (Chinese / Email / phone / URL / IP / ID / date). Also tests replace and split. All matching runs locally.

Steps

  1. Type the regex (without surrounding //) and choose flags
  2. Type the test string in the text field
  3. Tool highlights all matches and lists capture groups for each
  4. Dialect switch: JavaScript (default), PCRE, Python re, Java, Go
  5. Replace mode: enter a replace template (use $1, $2 for groups), see the output
  6. Split mode: split the string by the regex into an array
  7. One-click insert from common library: Chinese, Email, phone, URL, IP, ID, date, IPv4, IPv6
  8. Code snippet generation: wrap the regex as JS / Python / Java / Go test code

FAQ

Why does my regex match in JS but not in Python?
Regex dialects differ. Common differences: 1) JS does not support lookbehind (?<=); Python does; 2) JS does not support atomic groups (?>); 3) Python’s \d matches [0-9] only by default; JS \d in Unicode mode is still ASCII, but some languages have Unicode digits; 4) JS . does not match newlines; Python . also not (needs re.DOTALL). The tool supports dialect switching for cross-checking.
Greedy (.*) vs lazy (.*?)?
Greedy: as long as possible, with backtracking. `<.*>` matches `<a><b>` whole. Lazy: as short as possible. `<.*?>` matches just `<a>`. Use lazy to extract HTML tags or quoted strings; use greedy to capture entire text.
How to use named capture groups (?<name>...)?
JS (ES2018+): `(?<year>\d{4})-(?<month>\d{2})`, access via m.groups.year. Python: `(?P<year>\d{4})`. Benefits: code readability, no positional shifts on edits. PHP / older JS may not support; fall back to numbered captures $1 $2.
How to match Chinese characters?
Simple: `[\u4e00-\u9fa5]` matches BMP CJK characters (most common range). Complete: `\p{Script=Han}` matches all Han characters (including extensions; requires Unicode flag /u). Pure Chinese paragraph: `^[\u4e00-\u9fa5]+$`. Contains Chinese: `[\u4e00-\u9fa5]+`.
Why does regex testing sometimes hang?
Catastrophic backtracking. Patterns like `(a+)+` or `(.*)+` have exponential backtracking on long inputs. The tool has a 500ms timeout and shows the suspect part. Fix: use atomic groups (?>...) or possessive quantifiers a++ (where supported), or restructure the regex to eliminate nested quantifiers.

Use cases

  • Data validation: form input check (phone, email, ID, IP)
  • Log parsing: extract timestamps, status codes, URLs, errors
  • Bulk replace: rename strings across codebase / documents
  • URL routing: convert /user/:id to a regex for web framework matching
  • Scraping: extract specific patterns from HTML text

Use cases

Form validation, log parsing, code-base bulk replace, URL routing, web scraping. Daily developer tool. Multi-dialect cross-check, named captures, replace/split test, common regex library are the differentiators. Beware catastrophic backtracking.