usefmtly

Regex Tester & Debugger

Regex Tester — Free online regex tester. Test regular expressions against any text with live match highlighting. Supports global, case-insensitive, multiline, and dotAll flags. Shows all matches with capture groups. No signup required.

Flags
0Matches
gFlags
No matchStatus
Pattern
//g
Test String
Highlighted Output
Highlighted matches appear here…

Regex syntax quick reference

PatternMatchesExample
.Any character except newline. → a, 1, @
\dAny digit (0–9)\d+ → 123
\wWord character (letters, digits, _)\w+ → hello_world
\sWhitespace (space, tab, newline)\s+ → spaces
^Start of string/line^Hello → "Hello world"
$End of string/lineworld$ → "Hello world"
\bWord boundary\bcat\b → cat (not "catch")
[abc]Character class — a, b, or c[aeiou] → vowels
[^abc]Negated class — not a, b, or c[^0-9] → non-digits
(abc)Capture group(\d+) → captures digits
a|bAlternation — a or bcat|dog → matches either
a*Zero or more of ago* → g, go, goo
a+One or more of ago+ → go, goo (not g)
a?Zero or one of acolou?r → color or colour
a{3}Exactly 3 of a\d{4} → 2024
a{2,4}Between 2 and 4 of a\d{2,4} → 12, 123, 1234

Common regex patterns

Email address[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}
URLhttps?:\/\/[^\s]+
IPv4 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])
Phone (US)\(\d{3}\)\s?\d{3}-\d{4}
HEX color#(?:[0-9a-fA-F]{3}){1,2}\b
HTML tag<[^>]+>
Whitespace only^\s*$

Greedy vs. lazy quantifiers

By default, quantifiers like * and + are greedy — they match as much text as possible. Adding a ? after them makes them lazy — they match as little as possible.

PatternTypeOn <b>bold</b> text
<.*>GreedyMatches entire <b>bold</b>
<.*?>LazyMatches just <b> then </b>

Frequently Asked Questions

What is a regular expression?

A regular expression (regex) is a sequence of characters that defines a search pattern. It is used to find, match, or replace text that follows a specific pattern. For example, the regex \d+ matches one or more digits, and [A-Z][a-z]+ matches a capital letter followed by lowercase letters. Regex is supported in nearly every programming language.

What do the flags do?

The g (global) flag finds all matches instead of stopping at the first one. The i (ignoreCase) flag makes the match case-insensitive — "Hello" and "hello" are treated as equal. The m (multiline) flag makes ^ and $ match the start and end of each line, not just the whole string. The s (dotAll) flag makes the dot (.) match newline characters too.

How do capture groups work?

Capture groups are defined with parentheses in your pattern. For example, (\d{4})-(\d{2})-(\d{2}) has three groups that capture year, month, and day from a date string. The tool shows each group's value for every match. Named capture groups use the syntax (?<name>pattern) and appear with their label.

Why does my regex match too much or too little?

Common causes: quantifiers like * and + are greedy by default — add ? after them (.*?) to make them lazy. The dot (.) does not match newlines unless you enable the s flag. Anchors ^ and $ only match the whole string unless you enable the m flag. Use \b for word boundaries to avoid partial word matches.

What regex syntax is supported?

This tool uses JavaScript's native RegExp engine, which supports most standard regex features: character classes ([abc]), quantifiers (*, +, ?, {n,m}), anchors (^, $, \b), groups ((...) and (?<name>...)), lookaheads/lookbehinds, and common shorthand classes (\d, \w, \s).

Related Tools