Regex Tester

Test and debug regular expressions interactively. Supports global, case-insensitive, multiline, and dotAll flags. Shows all matches, capture groups, and highlights results in real time. Free, works in your browser.

Did we solve your problem today?

What is a Regular Expression?

A regular expression (regex or regexp) is a sequence of characters that forms a search pattern. You can use this pattern to match, find, replace, or validate strings in text. Regular expressions are supported in virtually every programming language — JavaScript, Python, Java, Go, PHP, Ruby, and many others — as well as in text editors, database engines, and command-line tools like grep and sed.

At their core, regular expressions describe what text should look like. A regex like \d{3}-\d{4} matches exactly three digits, a hyphen, and four more digits — a format common in phone numbers. A regex like [a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,} matches email addresses.

How to Use the Regex Tester

  1. Enter your regular expression in the Regular Expression field.
  2. Paste or type the text you want to test in the Test String area.
  3. Matches are highlighted in real time. The panel on the right shows all matches with their index positions and any capture groups.
  4. Use the flag checkboxes to toggle global (g), case-insensitive (i), multiline (m), and dotAll (s) modes.
  5. Click any snippet button to load a ready-made pattern for common use cases.

Regex Flags Explained

FlagLetterEffect
GlobalgFind all matches, not just the first one
Ignore caseiMatch letters regardless of case (A = a)
Multilinem^ and $ match start/end of each line, not just the whole string
DotAllsThe dot . matches newline characters as well

You can combine flags freely. For example, gi matches all occurrences case-insensitively.

Regex Syntax Quick Reference

PatternMatches
.Any character except newline (with s flag: including newline)
\dAny digit (0–9)
\wAny word character (letter, digit, underscore)
\sAny whitespace (space, tab, newline)
\bWord boundary
^Start of string (or line with m flag)
$End of string (or line with m flag)
[abc]Any character in the set: a, b, or c
[^abc]Any character NOT in the set
a|bEither a or b (alternation)
(...)Capture group
(?<name>...)Named capture group
(?:...)Non-capturing group
a{3}Exactly 3 repetitions of a
a{2,4}Between 2 and 4 repetitions
a+One or more repetitions (greedy)
a*Zero or more repetitions
a?Zero or one repetition

Capture Groups

Capture groups let you extract specific parts of a match. Enclose any part of your pattern in parentheses to create a capture group. For example, in the pattern (\d{4})-(\d{2})-(\d{2}) applied to 2024-06-07, group 1 captures 2024, group 2 captures 06, and group 3 captures 07.

Named groups ((?<year>\d{4})) make the captured value accessible by name rather than index, which is useful when the pattern has many groups.

Common Regex Patterns

The snippet bar above the pattern field provides ready-made patterns for:

Privacy

All regex matching runs entirely in your browser using the built-in JavaScript RegExp engine. Your patterns and test strings never leave your device and are not stored anywhere.

FAQ

What is a regular expression?

A regular expression (regex) is a sequence of characters that defines a search pattern. It is used to match, search, and manipulate strings. Regular expressions are supported in virtually all programming languages and many text editors.

What regex flags does this tool support?

This tool supports four flags: g (global — find all matches, not just the first), i (ignore case), m (multiline — ^ and $ match line boundaries), and s (dotAll — dot matches newlines). You can combine any flags.

What are capture groups?

Capture groups are parts of a regex pattern enclosed in parentheses. When a match is found, each group captures the substring matched by that part of the pattern. Named groups use the syntax (?<name>...) and are shown separately.

Is my data sent to a server?

No. All regex matching runs locally in your browser using the built-in JavaScript RegExp engine. Your patterns and test text never leave your device.