Developer

Regex Tester & Explainer

Test, debug, and understand regular expressions in real time

//
7 matches

Match preview

The Quick Brown Fox jumps over the Lazy Dog. JavaScript is a programming language.

Match details

#MatchIndexLength
1The03
2Quick45
3Brown105
4Fox163
5Lazy354
6Dog403
7Java454

How to Use This Regex Tester

Enter a regular expression in the pattern field, then type or paste test text in the input area. All matches are highlighted in real time. Use the flag toggles to enable global (g), case-insensitive (i), multiline (m), or dotAll (s) matching. The match panel below shows each match's value, position, and any captured groups.

Regular Expression Syntax Quick Reference

Anchors

  • ^ β€” start of string (or line with m flag)
  • $ β€” end of string (or line with m flag)
  • \b β€” word boundary

Character Classes

  • \d β€” digit (0–9)
  • \D β€” non-digit
  • \w β€” word character [a-zA-Z0-9_]
  • \W β€” non-word character
  • \s β€” whitespace
  • . β€” any character except newline (or including newline with s flag)
  • [abc] β€” character class: a, b, or c
  • [^abc] β€” negated class: anything except a, b, c
  • [a-z] β€” character range

Quantifiers

  • * β€” 0 or more (greedy)
  • + β€” 1 or more (greedy)
  • ? β€” 0 or 1 (greedy)
  • {n} β€” exactly n times
  • {n,m} β€” between n and m times
  • Add ? after any quantifier to make it lazy: *?, +?

Groups & Alternation

  • (abc) β€” capturing group
  • (?:abc) β€” non-capturing group
  • (?<name>abc) β€” named capturing group
  • a|b β€” alternation (a or b)

Lookahead & Lookbehind

  • (?=abc) β€” positive lookahead
  • (?!abc) β€” negative lookahead
  • (?<=abc) β€” positive lookbehind
  • (?<!abc) β€” negative lookbehind

Common Regex Patterns

  • Email (basic): [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
  • URL: https?:\/\/[^\s/$.?#].[^\s]*
  • IP address: \b(?:\d{1,3}\.){3}\d{1,3}\b
  • Date (YYYY-MM-DD): \d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])
  • Hex color: #(?:[0-9a-fA-F]{3}){1,2}\b
  • US phone: \(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}
  • Digits only: ^\d+$
  • Username (3–20 chars, alphanumeric + underscore): ^[a-zA-Z0-9_]{3,20}$

Frequently Asked Questions

What is a regular expression (regex)?
A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. It is used to match, find, replace, or split strings. For example, the pattern \d{3}-\d{4} matches phone number formats like "555-1234". Regex is supported in virtually every programming language and text editor.
What do the regex flags do?
Flags modify how the regex engine matches. g (global) finds all matches instead of stopping at the first. i (case-insensitive) makes matching ignore uppercase/lowercase differences. m (multiline) makes ^ and $ match the start and end of each line instead of the entire string. s (dotAll) makes the . metacharacter match newline characters in addition to all other characters.
What is a capture group in regex?
A capture group is a portion of the regex wrapped in parentheses ( ) that captures the matched text for later use. For example, (\d{4})-(\d{2})-(\d{2}) has three groups that capture year, month, and day from a date. Named groups use the syntax (?<name>...) so you can reference the captured text by name instead of by position number.
What are the most common regex metacharacters?
. matches any character (except newline without s flag). ^ matches the start of a string (or line with m). $ matches the end. \d matches any digit (0–9). \w matches word characters (letters, digits, underscore). \s matches whitespace. * means 0 or more. + means 1 or more. ? means 0 or 1. {n,m} specifies a quantity range. [] defines a character class. | is OR. \\ escapes a literal special character.
How do I match a literal dot or special character?
Prefix the special character with a backslash to escape it. To match a literal dot, write \.. To match a literal dollar sign, write \$. To match a literal backslash, write \\. Without escaping, special characters like . $ * + ? ( ) [ ] { } ^ | are interpreted as metacharacters.
What is the difference between greedy and lazy quantifiers?
Greedy quantifiers (*, +, {n,m}) match as much text as possible. Lazy quantifiers (*?, +?, {n,m}?) match as little as possible. For example, given the HTML string <b>bold</b><i>italic</i>, the greedy pattern <.+> matches the entire string from first < to last >, while the lazy <.+?> matches only <b>. Lazy quantifiers are often more useful when extracting specific tags or delimited content.