Regex Tester

Test regular expressions online with live match highlighting. Try patterns against sample text, inspect capture groups, and preview find-and-replace results instantly.

Copied
Test string0 matches
Highlighted matches

    
Matches

  

JavaScript regex flags cheat sheet

FlagNameEffect
gglobalFind all matches, not just the first
iignoreCaseCase-insensitive matching
mmultiline^ and $ match line boundaries, not just string boundaries
sdotAll. also matches newline characters
uunicodeTreats the pattern as a sequence of Unicode code points

Common pattern examples

PurposePattern
Email address^[\w.+-]+@[\w-]+\.[a-zA-Z]{2,}$
URLhttps?:\/\/[^\s]+
Digits only^\d+$
UUID^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
HTML tag<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)

Frequently asked questions

How do I test a regex online?

Type a pattern into the field above the test string. Matches are highlighted live as you type, with no need to click a button.

How do I use capture groups in the regex tester?

Wrap part of your pattern in parentheses, for example (\d+). Each match's capture groups are listed below the highlighted text.

What is the difference between the g flag and no flag?

Without the g (global) flag, a regex stops after finding the first match. With g, it finds every non-overlapping match in the string. This tool respects your chosen flags exactly, so unchecking g will show only the first match, matching real JavaScript behavior.

What do the i, m and s flags do?

i makes matching case-insensitive. m makes ^ and $ match the start/end of each line rather than the whole string. s (dotAll) makes . also match newline characters, which it doesn't by default.

Is JavaScript regex the same as PCRE or Python regex?

Mostly similar but not identical. JavaScript regex has its own syntax for named groups, lookbehind support varies by engine version, and some features common in PCRE (like atomic groups or possessive quantifiers) aren't supported. This tool runs your pattern through the actual browser JavaScript engine, so results match what you'd get in real JS code.

Related tools