//
Flags:
Test Text3 matches
3 lines·54 chars
Matches3 matches
0.5 ms
Match 1Ln 1, Col 1pos: 017
Full match: hello@example.com
Capture Groups (2)
Group 1:hello
Group 2:example.com
Match 2Ln 2, Col 1pos: 1832
Full match: test@gmail.com
Capture Groups (2)
Group 1:test
Group 2:gmail.com
Match 3Ln 3, Col 1pos: 3354
Full match: contact@ashusevim.dev
Capture Groups (2)
Group 1:contact
Group 2:ashusevim.dev
Your regex and test data stay in your browser.
3 lines · 54 bytes

What is a Regular Expression (Regex)?

A regular expression (often abbreviated as regex or regexp) is a sequence of characters that forms a search pattern. It provides a concise, formal language to locate, extract, validate, or replace patterns within strings across virtually every modern programming language, including JavaScript, TypeScript, Python, Go, and Rust.

Unlike static substring lookups, regular expressions describe complex syntax rules using character classes, quantifiers, lookaheads, and capture groups. Whether validating email addresses, extracting dates from logs, or sanitizing user inputs, regular expressions are essential everyday developer tools.

How to Use the Regex Tester & Playground

This Regex Toolkit is designed for rapid iteration with zero latency:

1. Write or Paste Pattern

Enter your pattern inside the pattern bar. Toggle flags like g (global), i (ignore case), or m (multiline) with one click.

2. Enter Test Text

Type or paste sample input into the Test Text editor. Matching substrings are highlighted live with alternating contrast markers and line numbers.

3. Inspect Matches & Groups

Examine full match spans, line and column coordinates, numbered groups ($1, $2), and named capture groups.

4. Explain & Generate

Switch to the Explain tab to decode complex expressions into human-readable steps, or use the Generator to turn English into regexes.

JavaScript Regular Expressions Guide

In JavaScript and TypeScript, regular expressions are instances of the built-in RegExp object. You can create them using literal notation or the constructor:

// 1. RegExp literal (compiled at evaluation time)
const emailRegex = /^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,}$/i;

// 2. Testing boolean match
const isValid = emailRegex.test("developer@example.com"); // true

// 3. Extracting all matches with groups (ES2020+)
const text = "item 42 and item 99";
const matches = [...text.matchAll(/item (\d+)/g)];
for (const match of matches) {
  console.log(match[0], match[1]); // "item 42", "42"
}

// 4. Replacing with backreferences
const formatted = "2026-09-03".replace(/(\d{4})-(\d{2})-(\d{2})/, "$2/$3/$1");
// formatted === "09/03/2026"

Core RegExp Flags in Modern JavaScript:

  • g (Global): Tests against all matches rather than halting at the first match.
  • i (Ignore Case): Case-insensitive matching where A-Z matches a-z.
  • m (Multiline): Makes ^ and $ match the start and end of each line instead of the entire string.
  • s (DotAll): Allows the dot wildcard (.) to match newline characters (\n, \r).
  • u (Unicode): Treats the pattern as a sequence of Unicode code points.
  • y (Sticky): Matches only from the index indicated by lastIndex.
  • d (HasIndices): Provides exact start and end offset arrays for captured substrings.

Common Regular Expression Examples

Email Address Validation^[\w.%+-]+@[\w.-]+\.[a-zA-Z]{2,}$

Validates email address syntax while allowing plus addressing and multi-level subdomains.

ISO 8601 Date (YYYY-MM-DD)^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$

Matches standard calendar date strings and bounds months to 01-12 and days to 01-31.

Strong Password Policy^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&#_]).{8,}$

Enforces at least 8 characters with at least one lowercase letter, uppercase letter, digit, and special symbol.

UUID v4 Format[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}

Matches canonical 128-bit universally unique identifiers conforming to RFC 4122 specifications.

Frequently Asked Questions (FAQ)

Is my regex or test data uploaded to any server?

No. 100% of the compilation, execution, explanation, replacement, and splitting takes place inside your web browser. No regex patterns or test texts are sent over the network or logged anywhere.

Which regex flavor / dialect does this tool support?

This tool runs the native ECMAScript (JavaScript / TypeScript) RegExp engine, which supports all standard features including lookaheads ((?=...)), lookbehinds ((?<=...)), named capture groups ((?<name>...)), and unicode property escapes.

What is ReDoS (Regular Expression Denial of Service)?

ReDoS occurs when an evil regex containing nested quantifiers (such as (a+)+$) experiences exponential backtracking against non-matching text. This tool safeguards against runaway loops with iteration and time guards to keep your browser responsive.