Regex Tester

Regex Tester

Test regular expressions against sample text with live match highlighting and capture group extraction.

Regular Expression
Test String
Highlighted Matches
⚠️

Disclaimer: This tool runs entirely in your browser -- nothing you enter is sent to or stored on our servers.

Regex Syntax Quick Reference

Regular expressions (regex) are patterns for matching, searching, and manipulating text. Core syntax: . (any character), * (0 or more), + (1 or more), ? (0 or 1), ^ (start), $ (end), [] (character class), () (capture group), | (OR). Quantifiers: {n} (exactly n), {n,m} (between n and m).

Common patterns: email validation ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$; Indian mobile number ^[6-9]\d{9}$. Flags: g (global -- find all matches, not just the first), i (case-insensitive), m (multiline -- ^ and $ match per line rather than per string). This tester highlights every match in real time as you type, making it fast to iterate on a pattern.

Worked Example

Pattern \b\w+@\w+\.\w+\b with the g flag against the sample text "Email me at hello@smartutilz.com or support@example.org" finds 2 matches: hello@smartutilz.com and support@example.org -- demonstrating a simplified (non-RFC-complete) email pattern useful for quick validation.

Second Worked Example: Pulling Order Codes

Paste this into the test string: Order A-102 shipped, order B-7 pending, order C-2045 done. Then try three patterns with the g flag on.

The tester runs the browser’s own JavaScript regular expression engine, so what you see here is what new RegExp() will do in your front-end or Node code.

Common Mistakes

Where You Would Use This

Tips for Building Patterns

Build a pattern in small steps. Start with a literal piece of the text you want, confirm it highlights, and then replace parts with classes such as \d or \w and add quantifiers one at a time. Keep a few lines of text that should not match in the test string, because a pattern that matches too much is as wrong as one that matches too little. When the pattern is finished, copy it into your code and escape backslashes as that language requires.

Frequently Asked Questions

Without the 'g' (global) flag, a regex match operation stops after finding the first match in your text. With 'g' enabled, it continues scanning and finds every non-overlapping match in the entire string -- essential when you want to count or highlight all occurrences, not just the first one.
By default, ^ and $ match only the very start and very end of the entire input string. Enable the 'm' (multiline) flag to make ^ and $ match the start and end of each individual line within a multi-line string instead.
This tester uses your browser's native JavaScript RegExp engine, so it supports the full JavaScript regex feature set (lookaheads, lookbehinds, named groups, unicode property escapes, etc.) -- but note that JavaScript regex syntax differs slightly from other languages like Python (PCRE) or PHP, so a pattern tested here should be re-verified if you're deploying it in a different language's regex engine.