Type your pattern in the first field and test text in the second. Matches highlight live.

Flags (toggle each letter)

  • g — global: find all matches (not just the first)
  • i — case-insensitive: Hello matches hello
  • m — multiline: ^ and $ match line starts/ends
  • s — dotAll: . also matches newlines

Replace mode

Enter a replacement string to see what the text looks like after substitution. Use $1, $2… to reference capture groups.

Tip: Without the g flag, only the first match is replaced/found.
/ /
Enter a pattern to start matching
Test text will appear here with matches highlighted…
Replace Result
Regex quick reference

A regular expression is a pattern that describes a set of strings. The test string is scanned and every match is highlighted in real time. Use the flags to control matching: g finds all occurrences (not just the first), i ignores case, m makes ^ and $ match per line instead of the whole string.

Quantifiers

* (0 or more), + (1 or more), ? (0 or 1), {3} (exactly 3), {2,5} (2 to 5 times). Default is greedy — matches as many characters as possible. Add ? to make lazy (+?) — matches as few as possible.

Character classes

[abc] matches any of a, b, c. [a-z] any lowercase letter. [^abc] anything except a, b, c. Shortcuts: \d = digits, \w = word chars ([a-zA-Z0-9_]), \s = whitespace, . = any char except newline.

Capture groups

(pattern) captures what it matches — visible as numbered groups in the match details below the test string. The Replace tab references them as $1, $2…. Use (?:pattern) to group without capturing when you only need to apply a quantifier.

Anchors & lookaheads

^ = start of string, $ = end, \b = word boundary. Lookahead (?=…) asserts what follows without consuming characters. (?!…) is negative. Example: \d+(?= dollars) matches a number only when followed by " dollars".