Text tool
Regex Tester
Test JavaScript regular expressions with live match highlighting, capture-group details, replacement previews, reusable test cases, plain-language token explanations, and copy-ready code snippets.
🔒 100% private browser processing
Your pattern, test text, uploaded files, matches, and replacement output stay on your device. Evaluation runs inside a temporary browser worker and stops automatically if it exceeds the safety limit.
Regular expression
JavaScript RegExp syntax · maximum 500 characters
Test text
sample-log.txt · 183 B
Find and replace
Use JavaScript replacement syntax such as $&, $1, or $<name>.
Pattern library
Load a practical expression, sample input, and recommended flags.
Result preview
Ready
Matches
0
0 matched characters
Text coverage
0.0%
183 source characters
Capture values
0
0 named captures
Test cases
0/3
Ready
Code generator
Use this regex in your project
Snippets translate the current pattern, common flags, and replacement text. Regex flavor differences may require manual adjustment.
const pattern = /\b(?<level>ERROR|WARN)\b.*?\b(?<code>[A-Z]{2,5}-\d{3})\b/g;
const matches = pattern.global
? [...text.matchAll(pattern)]
: [pattern.exec(text)].filter(Boolean);
const replaced = text.replace(pattern, "[$<level>] incident $<code>");Live matching without blocking the page
Every evaluation runs in a temporary Web Worker. A safety timeout stops patterns that take too long, while static checks surface common nested-quantifier and broad-wildcard risks before deployment.
Inspect every useful detail
Review match ranges, numbered groups, named groups, replacement output, test-case results, matched-text coverage, execution timing, and a token-by-token explanation in one workspace.
How to use the Regex Tester
Enter a pattern
Type a JavaScript regular expression or load a practical preset, then select the flags that control matching behavior.
Add realistic input
Paste text, open a local text or code file, and inspect highlighted matches, positions, capture groups, and safety feedback.
Verify and export
Preview replacements, create pass/fail test cases, copy a language snippet, or download complete match data as JSON.
Supported JavaScript regex features
The tester uses your browser's native RegExp engine, so modern features depend on browser support. Common production patterns work without sending input to an external service.
Performance warnings are heuristic
Static warnings identify several common backtracking structures, but they do not prove that a pattern is safe or unsafe. Test expressions against realistic long, failing inputs before using them on untrusted data.
The browser timeout protects this page from many slow evaluations; it does not replace server-side limits, input caps, or production monitoring.
Related Xepoca tools
Text Diff Checker
Compare pattern revisions, generated output, or transformed text.
JSON Formatter
Validate and format downloaded match data or API examples.
Markdown Previewer
Preview documentation that contains regex examples and code blocks.
Remove Duplicate Lines
Clean line-based data before testing or replacing patterns.
Frequently asked questions
Which regex flavor does this tester use?+
Matches and replacements use the native JavaScript RegExp engine in your browser. The generated Python, PHP, and Java snippets translate common flags, but advanced syntax can differ between regex flavors.
Are my pattern, text, or files uploaded?+
No. File reading, expression evaluation, highlighting, replacement, test cases, clipboard actions, and downloads happen locally in your browser. Xepoca does not upload or store the content.
Why did my pattern stop for safety?+
The expression exceeded the worker time limit on the current input. Slow failures are often caused by nested quantifiers, ambiguous repeated alternatives, or multiple broad wildcards. Narrow the pattern or reduce the input while debugging.
What do the regex flags mean?+
Global finds every match; ignore-case removes case sensitivity; multiline changes the behavior of start and end anchors; dot-all lets the dot match line breaks; Unicode enables Unicode-aware parsing; sticky matches only at the current lastIndex position.
How do replacement groups work?+
Use $& for the full match, $1 through $99 for numbered capture groups, and $<name> for named capture groups. The replacement preview follows JavaScript String.replace behavior, including whether the global flag is enabled.
Can I test positive and negative examples?+
Yes. Add up to ten test cases and mark each one as expected to match or expected not to match. The suite updates automatically whenever the pattern, flags, or examples change.
Does the explanation understand every regex perfectly?+
No. The token explanation is a practical parser for common JavaScript regex syntax, not a complete formal grammar. It is useful for learning and review, but the native engine remains the source of truth for actual matching.