Skip to content
CornerTools

Regex Tester & Validator

Test and debug regular expressions with live matching, flags, and error reporting.

1

Regex breakdown

TokenExplanation
Enter a regex to see explanation

Matches (0)

#MatchLineColumn
No matches
Flags

Tests a regular expression against your text as you type: it reports whether the pattern is valid, lists every match with its line and column, and breaks the pattern into tokens with a plain explanation of each. It uses JavaScript's regex engine, in your browser.

How to use it

Type the pattern without surrounding slashes — \d+, not /\d+/g — and set flags with the switches:

  • Global (g) — find every match; off, only the first. On by default.
  • Ignore case (i) — letters match either case.
  • Multiline (m) — ^ and $ match at the start and end of each line, not only of the whole text.
  • Dot matches newline (s) — . also matches line breaks.
  • Unicode (u) — full Unicode matching, needed for \p{L} classes and emoji.

Columns in the match table count from 1. The table lists the first 1,000 matches; the count above it covers them all. Matching that takes longer than 1 second is stopped with a note: nested quantifiers such as (a+)+ double their running time with each extra character of text they almost match. The breakdown lists each token with what it matches, reading ^, $ and . by the flags that are on; a character class is described as a whole.

Engine differences

Patterns run on JavaScript's engine, which behaves like most modern ones for everyday patterns. Some features differ elsewhere: possessive quantifiers and atomic groups exist in PCRE and Java but not in JavaScript, and Python and Go name groups differently. Test in the engine you will deploy to when using advanced features.

Examples

Why the global flag matters

Pattern
\d+
Text
Order 42 shipped 3 items
With g flag
"42", "3"
Without g flag
"42"

Without the global flag, matching stops at the first match.

Common patterns

Frequently used patterns and what they match, with the global flag
PatternMatchesExample textFound
\d+One or more digits"Order 42 shipped 3 items""42", "3"
\b\w+@\w+\.\w+\bA simple email address"Mail anna@example.com today""anna@example.com"
^\s+|\s+$Spaces at the start or end" padded "" ", " "
\b[A-Z][a-z]+\bCapitalised words"Anna met Ben in Pune""Anna", "Ben", "Pune"
#[0-9a-fA-F]{6}\bHex colour codes"Use #1e90ff or #FFF""#1e90ff"

See also