Regex Tester
Test regular expressions against any text in real time.
What is a regular expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. Originally developed in the 1950s by mathematician Stephen Cole Kleene, regex is now supported in virtually every programming language and text editor. It enables complex search, validation, and text transformation with concise syntax.
Essential regex syntax reference
| Pattern | Meaning | Example |
|---|---|---|
| . | Any character except newline | a.c matches "abc", "a1c", "a c" |
| ^ | Start of string | ^Hello matches "Hello world" but not "Say Hello" |
| $ | End of string | world$ matches "Hello world" but not "worldwide" |
| * | 0 or more of previous | ab* matches "a", "ab", "abb", "abbb" |
| + | 1 or more of previous | ab+ matches "ab", "abb" but not "a" |
| ? | 0 or 1 of previous | colou?r matches "color" and "colour" |
| {n,m} | Between n and m repetitions | [0-9]{2,4} matches 2β4 digit numbers |
| [abc] | Character class (a, b, or c) | [aeiou] matches any vowel |
| [^abc] | Negated class (not a, b, or c) | [^0-9] matches any non-digit |
| d | Any digit [0-9] | d{3}-d{4} matches phone "555-1234" |
| w | Word character [a-zA-Z0-9_] | w+ matches a single word |
| s | Whitespace (space, tab, newline) | s+ matches one or more spaces |
| (abc) | Capturing group | (d+)px captures number in "16px" |
| a|b | Alternation (a or b) | cat|dog matches "cat" or "dog" |
Regex flags
/pattern/flags
g β global: find all matches (not just first)
i β case-insensitive: /hello/i matches "Hello", "HELLO"
m β multiline: ^ and $ match start/end of each line
s β dotAll: . matches newline characters too
u β unicode: enable full Unicode matching
Common useful patterns
Email: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$/
URL: /https?://(www.)?[-a-zA-Z0-9@:%._+~#=]{2,256}.[a-z]{2,6}/
Phone (US): /^+?1?[-.s]?(?[0-9]{3})?[-.s]?[0-9]{3}[-.s]?[0-9]{4}$/
Postcode (UK): /^[A-Z]{1,2}[0-9][0-9A-Z]?s[0-9][A-Z]{2}$/
IPv4 address: /^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(25[0-5]|...)$/
Date (YYYY-MM-DD): /^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/Frequently asked questions
Which regex flavor does this tester use?
It uses JavaScript (ECMAScript) regular expressions β the same engine that runs in browsers and Node.js.
What do the g, i and m flags mean?
g = global (find all matches, not just the first), i = case-insensitive, m = multiline (^ and $ match the start and end of each line rather than the whole string).
Is my test data private?
Yes. Matching runs entirely in your browser; neither your pattern nor your test text is sent anywhere.
Why isnβt my pattern matching anything?
Common causes are forgetting to escape special characters (. * + ? ( ) [ ]), missing the g flag when you expect multiple matches, or anchors (^ $) that donβt account for multiline input.
Tests a regular expression against a string of text in real time. Matched sections are highlighted in yellow. Shows all matches with their exact positions.
Flags: g=global, i=case-insensitive, m=multiline The matched parts are highlighted in yellow. Match count and positions are shown below.