About this JavaScript regex tester
Regular expressions are easy to get subtly wrong. This workspace mirrors the RegExp engine available in Chrome, Firefox, Safari, or Edge so you can prototype patterns for input validation, log mining, or refactors before you paste them into production code.
The Match action lists every capture with indexes (when the global flag is present). The Replace action shows a simple preview where each match becomes the literal text [MATCH]—enough to reason about coverage without overwriting your source data.
Good fits for this page
- Sanity-checking email or phone patterns against real-world samples.
- Exploring how greedy versus lazy quantifiers change match length.
- Teaching teammates how multiline (
m) or case-insensitive (i) flags behave.
How to use this page
- Paste representative text on the left. Include edge cases you care about.
- Enter your pattern without surrounding slashes.
- Add flags such as
g,i, ormin the flags field (spaces are ignored). - Click Match to enumerate hits as JSON, or Replace for a quick substitution preview.
- Iterate until the status line reports the count you expect.
Performance & safety tips
Catastrophic backtracking can freeze the tab if a pattern combinatorially explodes. Start with small samples, then scale up. Never run untrusted regex against untrusted megabyte logs without safeguards.
Frequently asked questions
- Is this PCRE?
- No. It is JavaScript’s regex flavor. Lookaheads are supported, but some PCRE-only features are unavailable.
- Why do I see “No matches found”?
- Confirm the global flag when you expect multiple hits, and verify that special characters are not over-escaped in the pattern field.
- Can I use replacement templates?
- This UI uses a fixed placeholder for preview purposes. Move to your editor or tests for dollar-sign capture replacements.
- Does my sample text leave the browser?
- No. Matching executes locally.