Free Regex Tester
Test regular expressions against text in real time. See highlighted matches, groups, and match details.
g Global - find all matches · i Case-insensitive · m Multiline - ^ and $ match line boundaries · s Dotall - dot matches newline · u Unicode - full code-point matching · y Sticky - each match must start where the last one ended
Matches
Common uses
- Test Regex for Form ValidationWrite and test regular expressions for validating emails, phone numbers, postcodes, and other form inputs.
- Parse Server Logs with RegexWrite regex patterns to extract timestamps, IP addresses, error codes, and structured data from log files.
- Extract and Replace Text with RegexUse regex to find patterns, extract data, or prepare find-and-replace operations before running them in your editor.
- Test URL Routing PatternsWrite and test regex patterns for URL routing rules in Express, Nginx, and Apache.
- Extract Data with RegexBuild and test patterns to extract structured data from unstructured text, HTML, or markdown.
How It Works
This tool runs entirely in your browser using JavaScript's built-in RegExp engine — the same engine powering every script on every website you visit. No pattern, test text, or match result is ever sent to a server.
- 1Pattern compiled to RegExpAs you type, the tool calls new RegExp(pattern, flags) using the flags you've toggled (g, i, m, s, u, y). If the pattern is syntactically invalid, the caught error message is shown inline immediately — no submit button needed.
- 2exec() loop collects matchesThe engine runs re.exec(text) in a loop, recording each match's character index, length, full value, numbered capture groups, and any named groups. A safety cap of 10,000 matches prevents runaway patterns, and a zero-length match guard advances lastIndex to avoid infinite loops.
- 3Text split into highlighted spansA buildSegments function walks the match offsets and slices the source text into alternating unmatched and matched segments. Matched spans are wrapped in <mark> elements styled with cycling colors so overlapping or adjacent matches remain visually distinct.
- 4Replace mode via String.replaceSwitching to replace mode calls testText.replace(new RegExp(pattern, flags), replacement) directly, which means backreferences like $1 and $<name> work exactly as they would in JavaScript code. The result text is shown live and can be copied to the clipboard.
Related Tools
Gamepad Tester
Test a game controller in your browser: see every button, stick and trigger live, check stick drift, and try the vibration motors.
Touch Screen Test
Paint with your fingers to find dead zones on your touch screen, count how many touches it registers at once, and see pressure and contact size.
ENV File Validator
Lint a .env file for duplicate keys, bad spacing, and unquoted values — then get a cleaned, sorted version and a ready-to-commit .env.example. Runs in your browser.