Regex Tester
Test JavaScript regular expressions locally in your browser with matches, capture groups, and replacement preview.
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.
Browser-local processing
Regex Tester
How to use
Finish in three steps
- 01
Enter the JavaScript regex pattern without surrounding slashes; leading or trailing spaces are literal and are preserved.
- 02
Paste sample text that is safe to test and does not contain real secrets, tokens, or personal data.
- 03
Add g, i, m, s, u, or y flags and optional replacement text when needed.
- 04
Click “Test Regex” to inspect match count, index ranges, capture groups, and replacement output.
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.
FAQ
About this tool
Should I include /pattern/g slashes?
No. Enter only the pattern in the pattern field and put flags in the separate flags field.
Which flags are supported?
The flags g, i, m, s, u, and y are accepted. The tool adds global behavior internally to collect all preview rows; d and v are not accepted by this interface.
Can I test backend regex patterns here?
Use it as an early check only. Confirm final behavior in the backend language and realistic production input ranges because regex engines differ.
Is the text uploaded?
The current match and replacement handlers run in the browser without an upload API. This does not make the whole page, browser extensions, clipboard, or device a trusted environment, so redact secrets first.
Further reading
Related articles
Keep exploring
Related tools
Last updated: