Regex Tester

Write and test regular expressions with live match highlighting and a detailed group capture view. Supports all JavaScript RegExp flags. Runs entirely in your browser — nothing is sent to a server.

/ /
Test String
Match Details

Enter a pattern and test string to see matches

Replace with
❤️ Support CodeConverter.net and donate ❤️

Everything you need to know about regular expressions

What are regular expressions and when should you use them?

A regular expression (regex) is a sequence of characters that defines a search pattern. In JavaScript — and virtually every other programming language — regex enables you to match, extract, validate, and transform strings far more powerfully than simple string methods. A single regex pattern like /^[\w.-]+@[\w.-]+\.\w{2,}$/ can validate an email address that would otherwise require dozens of lines of imperative code.

Regex is the right tool when you need to validate input formats (emails, phone numbers, URLs, postcodes), extract structured data from unstructured text (log parsing, scraping), perform find-and-replace with conditional logic, or tokenize and split strings on complex boundaries. The key to writing good regex is testing it interactively — which is exactly what this tool is built for. Enter your pattern and test string above and the engine highlights every match in real time as you type.

Essential regex syntax
  • . any char  ·  \d digit  ·  \w word char
  • * 0+  ·  + 1+  ·  ? 0 or 1  ·  {n,m} range
  • ^ start  ·  $ end  ·  \b word boundary
  • [abc] char class  ·  (a|b) alternation
Capturing groups
  • (pattern) — captures and assigns group index
  • (?<name>pattern) — named capture group
  • (?:pattern) — non-capturing group
  • Back-reference groups via $1, $2 in replace
Flags explained
  • g — global: find all matches, not just first
  • i — case insensitive: A matches a
  • m — multiline: ^/$ match each line
  • s — dotall: . also matches \n
Lookaheads & lookbehinds
  • (?=...) — positive lookahead
  • (?!...) — negative lookahead
  • (?<=...) — positive lookbehind
  • (?<!...) — negative lookbehind
Common patterns
  • Email: [\w.-]+@[\w.-]+\.\w{2,}
  • URL: https?:\/\/[\w./?=&#-]+
  • Hex color: #[0-9a-fA-F]{3,6}
  • ISO date: \d{4}-\d{2}-\d{2}
100% private & client-side
  • All matching happens in your browser
  • Your patterns and test data never leave your device
  • Uses the native JS RegExp engine — zero deps
  • Works offline after first page load

How to avoid catastrophic backtracking in regex

Catastrophic backtracking (also called ReDoS — Regex Denial of Service) occurs when a regex engine explores an exponential number of paths through the pattern against a string that doesn't match. The classic trigger is nested quantifiers on overlapping character classes, such as (a+)+ or (\w+\s*)+ applied to a long input that nearly matches but ultimately fails. On long strings this can freeze a browser tab or take a server down.

The safest mitigation is to prefer atomic groups or possessive quantifiers where your regex engine supports them, be specific with character classes (use [0-9] rather than \d if you only want ASCII digits), avoid ambiguity between alternation branches, and always test your patterns against adversarial inputs that are long and don't match. This tester shows execution time so you can spot slow patterns early.