Skip to main content
DevBench
/.*/

Regex Tester

TextOffline-ready

Regex Tester tests JavaScript regular expressions against any input in real time. Type your pattern, pick the flags you need (g, i, m, s, u, v), and every match is highlighted instantly with colour-coded groups, named captures, and exact index positions. Use the Substitution tab to preview replace operations, the Code tab to export snippets for JavaScript, Python, PHP, or Go, and the Pattern Library to load 30 built-in example patterns.

Related: Text DiffFindInspectMarkdown Preview

Your files and inputs stay in your browser — nothing is uploaded or stored.

//
\b[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}\b(hover tokens for description)
Test Stringno matches
Match Highlights
The quick brown fox jumps over the lazy dog. Pack my box with five dozen liquor jugs. Contact: alice@example.com or bob.smith@company.org Dates: 2024-01-15, 2023-12-31 URLs: https://devbench.co.in and http://example.com/path?q=1 IP: 192.168.1.100

No matches found.

^Start of string / line (with m flag)
$End of string / line (with m flag)
\bWord boundary
\BNon-word boundary
\AStart of string (PCRE)
\ZEnd of string (PCRE)

How to use the Regex Tester

  1. Type your regular expression into the Pattern field — matches in the test string are highlighted immediately.
  2. Toggle flags as needed: g (global), i (case-insensitive), m (multiline), s (dotAll).
  3. Check the Match Details panel to see each match, its index, and every capturing group value.
  4. Switch to the Substitution tab, type a replacement string, and preview the result of String.replace() in real time.
  5. Use the Pattern Library to load one of 30 built-in example patterns, or the Code tab to copy the equivalent JavaScript, Python, Go, or PHP snippet.

What is a regular expression?

A regular expression (regex) is a sequence of characters that defines a search pattern. Regex is built into nearly every programming language — JavaScript, Python, Java, Go, Ruby — and is used for finding, extracting, validating, and transforming text. Our online regex tester gives you a live preview of every match as you type, so you can debug patterns without running any code.

Regex flags explained

Capture groups and substitution

Wrap part of your pattern in parentheses (...) to create a capture group. The tester shows each group's value separately in the match detail panel. Use the substitution field to replace matches — reference captured groups with $1, $2, etc. Named groups use the syntax (?<name>...) and can be referenced as $<name>.

Commonly used regex patterns