developer-tools

Regex Tester

Test JavaScript regular expressions locally in your browser with matches, capture groups, and replacement preview.

Tool workspace

The interactive tool requires JavaScript.

Instructions

1. Enter the JavaScript regex pattern without surrounding slashes; leading or trailing spaces are literal and are preserved.
2. Paste sample text that is safe to test and does not contain real secrets, tokens, or personal data.
3. Add g, i, m, s, u, or y flags and optional replacement text when needed.
4. Click “Test Regex” to inspect match count, index ranges, capture groups, and replacement output.

Enter a JavaScript regex pattern, sample text, flags, and optional replacement text to inspect match positions, capture groups, and replacement output. Processing stays in the browser, and the tool limits input size plus common catastrophic-backtracking patterns.

The Regex Tester uses browser JavaScript RegExp semantics. It supports g, i, m, s, u, and y flags, shows up to 100 matches, lists capture groups, and previews JavaScript replacement output. Use it for text extraction, log filters, and frontend validation drafts, not as a substitute for code review, performance testing, or another language's regex engine.

JavaScript regex semantics

The tool uses the current browser RegExp engine. It accepts g, i, m, s, u, and y; it does not expose newer or engine-dependent flags such as d or v. PCRE, Python, Java, and .NET differ, so verify migrated patterns in the target runtime.

Match and replacement preview

For pattern (?<code>\d{3}) and sample error 404, the result includes range [6, 9), match 404, and named group code=404. Preview matching and replacement are global internally even when g is omitted; y remains sticky, and an empty replacement field means no preview rather than delete-to-empty.

Backtracking risk boundary

The tool limits pattern length, sample length, and match count, and blocks common nested-quantifier patterns. That reduces browser-freeze risk but does not prove every complex expression is safe on every input.