Regex Tester
Use the CaseSwitch Regex Tester to try a JavaScript regular expression against sample text and see matches — without sending logs that might contain PII to a third-party tester. Enter a pattern, optional flags/replacement, and review matches. Testing runs in this browser.
Written by the CaseSwitch editorial team. We maintain these tools in the browser so drafts, keys, and images stay on your device.
Last reviewed: 23 July 2026
Processed locally in your browser. Nothing is sent to a server.
Paste or type text to convert. Output stays empty until there is input.
Character count: 0 · Word count: 0 · Line count: 0
Examples
Find email-like tokens
Input
ada@example.com bob@test.org
Output
Match 1: "ada@example.com" at index 0 Match 2: "bob@test.org" at index 16
Capture order ids
Input
order-123 order-99
Output
Match 1: "order-123" at index 0 Group 1: 123 Match 2: "order-99" at index 10 Group 1: 99
Replace all foo
Input
foo bar foo
Output
baz bar baz
No matches
Input
abc
Output
No matches found.
Date capture groups
Input
2024-01-15
Output
Match 1: "2024-01-15" at index 0 Group 1: 2024 Group 2: 01 Group 3: 15
How to use
- Enter a regular expression pattern and paste sample text.
- Add flags if needed. Optionally set a replacement to see rewrite output.
- Read match indices and groups, or copy the replaced text.
What this tool is for
Regex is easier to debug with live matches. This page compiles your pattern with the flags you set, lists match positions and groups, or runs a replace when you supply a replacement string. The dialect is JavaScript (ECMAScript) regex as your browser implements it — not PCRE or Python `re` in every detail.
How it works
The pattern is required. Flags default toward global matching (`g` is ensured). Without a replacement, matches are listed with indices and capture groups. With a replacement, `String.replace` runs and the output is the rewritten text. Invalid patterns fail. Empty match lists report “No matches found.”
When to use it
Validating an email-ish pattern on a short sample, extracting IDs from a log line, teaching capture groups, and trying a replace before you put it in code.
When not to use it
Catastrophic backtracking on huge pastes can freeze the tab. Do not paste production dumps with secrets. JS regex is not a replacement for a parser or an email RFC validator.
How it compares to related tools
Find and Replace can run replacements on a whole document. This tester emphasizes inspecting matches. URL Encode is unrelated.
Common mistakes
Forgetting to escape dots. Trusting a regex as a complete email validator. Nested quantifiers on long strings until the tab hangs. Assuming lookbehind works in every old browser.
JavaScript dialect notes
Lookaheads are widely available; lookbehind depends on the engine version. Unicode property escapes need the `u` flag. When you move a pattern to Python or PCRE, re-test — flavors differ on details like possessive quantifiers.
Replace mode vs match list
If you set a replacement string, the output panel shows the rewritten text (`foo` → `baz`). If replacement is empty, you get a match report instead. That split keeps teaching matches separate from editing.
Frequently asked questions
Which regex dialect is this?+
JavaScript (ECMAScript) regular expressions, as your browser implements them.
Why is my pattern slow?+
Nested quantifiers on long strings can explode. Narrow the sample and simplify the pattern. That is a regex hazard, not a site bug.
How do I test a replace?+
Provide a replacement string in the tool options. The output becomes the rewritten text.
Are matches global by default?+
The tester ensures a global flag so you see every match, not only the first.
Can it validate emails for production?+
Use it for experiments. Production email validation usually needs more than a quick regex.
Is my sample text uploaded?+
No. Matching runs in this browser. Still avoid pasting secrets.
Does this tool send my payload to CaseSwitch?+
No. Formatting, encoding, and naming conversions for this page run in your browser after load — your sample stays on the device.
Related guides
Read our original articles on this topic.
Related tools
Find and Replace Text
Renaming a term across a draft, normalizing spelling variants, stripping a repeated prefix, fixing a typo that appears dozens of times, and small regex cleanups (optional digits, `colou?r`-style variants, capture-friendly patterns). Test on a short sample before pasting a long document.
JSON Formatter
Debugging a 401 response, comparing two configs, preparing a gist, shrinking a JSON blob before embedding it in a test fixture, and checking whether a file is actually JSON before you commit it. If you need to escape a string as a JSON literal, use JSON Stringify instead. If you need YAML, use JSON to YAML after the JSON is valid.
Slug Generator
Blog posts, documentation pages, product listing URLs, knowledge-base articles, and CMS permalink fields when you have a working title and need a path before publish. Also useful for turning a noisy marketing headline into a short candidate slug you can still edit by hand.