Regex Tester Online — JavaScript Match & Replace

JavaScript regex workshop: set the pattern and test string, click Test for inline highlights and match cards with groups, or preview replace — all client-side, no upload.

Loading…
Regex tester — developer notes
JavaScript RegExp workshop: flags, cheat-sheet chips, inline highlights on the test string, and match cards with capture groups. Preview replace with $1 / $& — all client-side.

How testing works

Enter a pattern and test string, toggle flags (g/i/m/s/u/y), then click Test (or use an example / Sample). Matches update when you run the test — not while typing. The left pane highlights hits; the right pane lists match cards with groups. Replace mode also shows the substituted string. Pathological patterns can freeze the tab — keep experiments local and avoid nested quantifiers on large subjects.

Options

Flags (g / i / m / s / u / y)
Standard JavaScript RegExp flags. Global (g) finds all matches; ignoreCase (i), multiline (m), dotAll (s), unicode (u), and sticky (y) change matching semantics. Sticky (y) matches only at the start of the test string here because lastIndex is reset on every run.
Mode (match / replace)
Match lists hits only. Replace applies a substitution string with $1, $&, and related templates so you can preview rewrites.
Replace with
Shown when mode is replace. Supports JavaScript replacement patterns such as $1 for group 1 and $& for the full match.

Examples

Capture pairs

Pattern + test string

(\w+)=(\d+) on user=42 role=admin env=prod (flag g)

Result

1 match: user=42 → groups [user, 42] (other pairs need non-digit values — try the digits example)

Replace with $1

Pattern + test string

(\d+) → [$1] on x=10 (flag g)

Result

x=[10]

Related utilities

Need URL-safe labels? Use slugify. Generate secrets with the password generator.

Regex tester FAQ

Pattern debugging questions

Is this PCRE or Python regex?

No — this tool uses the browser’s JavaScript RegExp engine only (same flavor as in Node and modern browsers). There is no flavour switch.

Do I need to include / delimiters?

Don’t include / delimiters in the pattern field — or paste /pattern/flags and we’ll unwrap the pattern and merge flags automatically.

How does sticky (y) work here?

Sticky (y) matches only at the start of the test string here because lastIndex is reset on every run.

Can a pattern freeze my browser?

Yes. Catastrophic backtracking (ReDoS-style patterns) can hang the tab because execution is local. Prefer simple patterns and smaller subjects when experimenting. Very large match sets may be truncated.

Is the email example a full RFC validator?

No — the email-ish example is a practical pattern for demos, not a complete RFC 5322 validator.

Are named groups supported?

Yes. Named captures appear once as GROUP k (name) on each match card — not duplicated as a separate numbered row.

Is my text uploaded?

Never — testing stays in your browser.

Developer utilities

Timestamps, UUID, ULID, Nanoid, cron, passwords, regex, slugify, number bases, case, text diff, and chmod — all client-side.

Explore other tool categories

Minify

Shrink code and assets for production — minify JavaScript, CSS, HTML, JSON and XML before gzip or CDN deploy.

Beautify

Make code readable with consistent indentation — beautify JavaScript, CSS, TypeScript, SCSS, LESS, Markdown, GraphQL, SQL, YAML and more in your browser.

Unminify

Expand minified or compressed code — unminify JavaScript, CSS, TypeScript, SCSS, LESS, SQL, YAML and other formats when debugging or reviewing.

Conversion

Transform data between JSON, YAML, XML and CSV locally — no server uploads.

CSS preprocessors

Compile SCSS or LESS to standard CSS in the browser — pair with beautify or minify for a full stylesheet workflow.

JSON Tools

Validate, format, diff and explore JSON payloads — complementary to minifiers and converters.

SVG Tools

Preview, optimize with SVGO, export Data URI, resize, beautify, convert to JSX and validate SVG — all in your browser.

DevOps & Infra

Terraform HCL format/validate/minify, Dockerfile format & lint, Docker Compose and .env validation.

CI/CD

GitHub Actions and GitLab CI — format YAML and check workflow/job structure in your browser.

Logs & observability

Line-oriented JSON/NDJSON and Nginx/Apache access logs — format, filter, validate, and CSV/TSV.

Kubernetes

Multi-doc manifests, structural validate, Ingress/Deployment starters, and Helm values formatting.

Networking / IP

CIDR, subnets, and IPv4/IPv6 helpers — in your browser.

Security & tokens

JWKS, X.509 certificates, and secrets scan — browser-local.

API & schemas

OpenAPI tools to format, validate, and lint your specs.

Encoding

Encode or decode Base64, URL components and HTML entities — client-side only.

Text & Markdown

Count words, build Markdown TOCs, and clean line lists — all in your browser.

AI & LLM

Token counting, pricing estimates, and context-window fit — 100% browser-local.

Serialization

Serialize and deserialize PHP data structures beside JSON workflows.