.* Regex Tester Online — Test Regular Expressions

Test regular expressions with live match highlighting. See all matches, capture groups, and positions. Supports g, i, m, s flags. Free online regex tester.

Enter your regex pattern and test string, then see all matches highlighted in real-time. Capture groups are shown with their indices. Toggle flags (global, ignore-case, multiline, dotAll) and see results update instantly. Uses JavaScript's native RegExp engine.

/ /

How to Use

1

Enter a pattern

Type your regular expression in the pattern field. Use the checkboxes to enable flags: g (global), i (ignore case), m (multiline), s (dotAll).

2

Add your test string

Paste or type the string you want to test in the Test String area. All matches are highlighted live as you type.

3

Inspect matches

See the total match count, each match with its position, and any capture groups. Copy the verified pattern to use in your project.

Frequently Asked Questions

What is a regular expression? +
A regular expression (regex) is a sequence of characters that defines a search pattern. They are used to match, find, or replace text in strings. For example, /\d+/ matches one or more digits.
What are regex flags and what do they do? +
Flags modify how a regex works. g (global) finds all matches, not just the first. i (ignore case) makes matching case-insensitive. m (multiline) makes ^ and $ match line boundaries. s (dotAll) makes . match newlines.
What are capture groups? +
Capture groups (...) let you extract specific parts of a match. For example, /(\d{4})-(\d{2})-(\d{2})/ matches a date and captures year, month, and day in separate groups. Named groups use (?<name>...) syntax.
Why does my regex not find all matches? +
Without the g (global) flag, the regex stops after the first match. Enable the g flag to find all occurrences. Also ensure you have not accidentally added anchors (^ or $) that restrict matching.
Is any data sent to a server? +
No. All regex processing runs entirely in your browser using JavaScript's built-in RegExp engine. Your pattern and test string never leave your device.


Complete Guide: Regex Tester

What Is a Regular Expression and Why It Matters

A regular expression (regex) is a sequence of characters that defines a search pattern. The syntax traces back to Stephen Kleene's 1956 mathematical formalization of regular languages, implemented practically by Ken Thompson in 1968 for UNIX grep. Every modern programming language — JavaScript, Python, Go, Java, Rust — has a regex engine, and most use a variant of the PCRE (Perl-Compatible Regular Expressions) syntax.

Regex is indispensable for: form validation (email, phone, postal code), log parsing (extracting timestamps and error codes from millions of lines), search-and-replace in code editors, URL routing patterns, and data extraction from unstructured text. A well-written regex replaces dozens of lines of string manipulation code. A poorly-written one causes catastrophic backtracking that can hang a server under malicious input.

The learning curve is steep because regex patterns can look like line noise — /^(?!.*\.\.)(?!.*\.$)[^\W][\w.]{0,28}$/ — but the underlying rules are a small finite set. Master those rules and any pattern becomes readable.

How to Use the Regex Tester

  1. Enter your pattern in the pattern field (without surrounding slashes — the tool adds those).
  2. Set flags using the checkboxes: g (global — find all matches, not just first), i (case-insensitive), m (multiline — ^/$ match line boundaries), s (dotAll — . matches newlines too).
  3. Paste your test string in the text area. All matches highlight in real-time.
  4. Inspect the match list — each match shows its start/end index and any capture group values.
  5. Copy the verified pattern for use in your code.

Code Examples

// JavaScript: basic match and capture groups
const datePattern = /(\d{4})-(\d{2})-(\d{2})/g;
const str = 'Events: 2026-01-15, 2026-03-22';
for (const match of str.matchAll(datePattern)) {
  console.log(`Year: ${match[1]}, Month: ${match[2]}, Day: ${match[3]}`);
}

// Named capture groups (ES2018+) — far more readable
const namedDate = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/;
const { year, month, day } = '2026-05-08'.match(namedDate).groups;

// Lookahead / Lookbehind: find prices without including the $ sign
const pricePattern = /(?<=\$)\d+(\.\d{2})?/g;
'$12.99, $5, $199.00'.match(pricePattern); // ['12.99', '5', '199.00']

// Email validation (pragmatic — not RFC 5322 perfect)
const emailRx = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/i;

// URL slug validation
const slugRx = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;

Common Mistakes to Avoid

Comparison with Alternatives

String methods (.includes(), .startsWith(), .split()) are readable and fast for simple cases — prefer them when regex would be overkill. Parser combinator libraries (like Parsimmon for JS, pyparsing for Python) handle recursive grammars that regex cannot. Full-text search engines (Elasticsearch, PostgreSQL tsvector) are better for searching large text corpuses than regex scanning. Specialized validators (like validator.js) handle edge cases in email, URL, and credit card validation better than hand-rolled regex.

After validating your regex pattern, use the Text Diff tool to compare text transformations, or the Case Converter for systematic string manipulations.

Pro Tips

🧰 50+ Tools