Free No sign-up Client-side

Regex Tester

Test regular expressions against any string with live match highlighting, captured group display, and a replace mode — all running instantly in your browser.

Quick Samples

/
/gi
2 matches

Match Preview

Contact us at support@codercrafter.in or hello@example.com for help.
Match Details
1
support@codercrafter.in@ index 14
2
hello@example.com@ index 41

What is a regular expression?

A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. Regular expressions are used to match, search, extract, and replace text. They are supported natively in every major programming language and are among the most powerful text-processing tools available.

A regex pattern like /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/ validates email addresses. A pattern like /\b\d{10}\b/g finds all 10-digit phone numbers in a document. The syntax looks cryptic at first but follows consistent rules that become second nature with practice.

This tester uses JavaScript's native RegExp engine, making it perfect for testing patterns you'll use in browser JavaScript, Node.js, TypeScript, and most frontend frameworks. Flags, capture groups, named groups, lookaheads, and lookbehinds are all supported.

How to test a regex

  1. 1

    Enter your pattern

    Type your regex pattern in the Pattern field (without surrounding slashes). Set flags using the toggle buttons.

  2. 2

    Paste your test string

    Enter the text you want to match against. Matches are highlighted in real time as you type in either field.

  3. 3

    Inspect matches

    See each match, its position (index), and any captured groups below the test string. Switch to Replace mode to test substitutions.

Why use a dedicated regex tester

Instant feedback

See what your pattern matches in real time — no need to run code, refresh a browser, or print debug statements.

Catch mistakes before production

A regex that looks correct often has subtle issues — missed anchors, greedy vs lazy quantifiers, wrong flag. Test against real data before shipping.

Learn by experimenting

Trying different patterns against the same string is the fastest way to build regex intuition. Adjust one character and see exactly what changes.

Validate edge cases

Test your pattern against empty strings, very long strings, strings with newlines, and Unicode input — all the edge cases that bite in production.

Regex flags reference

  • g (global) — find ALL matches, not just the first. Without this flag, the regex stops at the first match.
  • i (case-insensitive) — /hello/i matches 'Hello', 'HELLO', 'hElLo'.
  • m (multiline) — ^ and $ match the start/end of each LINE, not just the whole string.
  • s (dotAll) — . matches newline characters (\n) in addition to all other characters. Without this, . skips newlines.
  • u (unicode) — enables full Unicode mode. Required for matching emoji, astral plane characters, and Unicode property escapes like \p{L}.
  • d (indices) — provides start/end index arrays for each match and capture group in the result.

Common regex patterns

  • Email (basic): ^[\w.-]+@[\w.-]+\.[a-z]{2,}$
  • URL: https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)
  • Indian mobile number: ^[6-9]\d{9}$
  • Hex color: #([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})
  • ISO date: \d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])
  • IP address (IPv4): \b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b

Frequently asked questions

Common causes: missing the g flag (only first match returned without it), anchors (^ $) being too strict, special characters not escaped (use \ before . * + ? [ ] { } ( ) ^ $ | \), or the m flag missing when matching across lines.

Greedy quantifiers (*, +, ?) match as MUCH as possible. Lazy versions (*?, +?, ??) match as LITTLE as possible. Example: given 'a<b>c</b>d', /<.*>/ matches '<b>c</b>' (greedy — everything between first < and last >), while /<.*?>/ matches '<b>' and '</b>' separately (lazy — stops at first >).

Parentheses create capture groups: /(\d{4})-(\d{2})-(\d{2})/ captures year, month, day from a date. In JavaScript, match[1] is the year, match[2] the month, match[3] the day. Named groups use (?<name>pattern) syntax: /(?<year>\d{4})-(?<month>\d{2})/ — then access as match.groups.year.

RegExp.test(str) returns true/false — fastest for simple yes/no checks. str.match(regex) returns an array of matches (or null). RegExp.exec(str) returns detailed match info including index and groups — use in a loop with the g flag for iterating all matches.

Escape it with a backslash: \. matches a literal dot (not 'any character'). \( \) match literal parentheses. \[ \] match literal brackets. In a JavaScript string, you need double backslashes: '\\.' or use a regex literal /\./ where single backslash works.

Need another tool?

Browse the full toolbox or dig into the blog for the engineering behind it.

Call UsWhatsApp