Regex Generator

Build regular expressions visually with pattern builder, character classes, quantifiers, and groups. Live preview with match highlighting, 20+ common patterns, and escaped output for every language.

Start building your regex...
Common Patterns — click to use
Live Preview & Match Details
Test String
Highlighted Matches
 
Match Groups
No matches yet

FAQ

How do I build a regex with this tool?
Use the Pattern Library tab to pick from 20+ common patterns, or switch to the Custom Builder tab to construct your own regex piece by piece using character classes, quantifiers, groups, and modifiers. Everything updates live as you build.
Can I test my regex against text?
Yes. Type or paste any text in the Test String area and matches are highlighted in real-time. Match groups and their positions are shown below the highlighted output.
What are the escaped outputs for?
Regex syntax varies between programming languages. The Escaped Output tab shows your regex properly formatted as a string literal for JavaScript, Python, Java, and PHP so you can paste it directly into your code.
What is the difference between capturing and non-capturing groups?
A capturing group (...) saves the matched text for back-references and extraction. A non-capturing group (?:...) groups content for quantifiers but doesn't create a capture, improving performance when you don't need the matched text.
Does this tool send my data anywhere?
No. Everything runs 100% in your browser. No text, patterns, or data are sent to any server.
How do I write a regex for email validation?
A practical pattern is ^[\w.+-]+@[\w-]+\.[\w.-]+$ — it accepts the common local-part characters, requires an @, and checks the domain has at least one dot. Full RFC 5322 compliance is far more complex and rarely needed; for most apps this pattern plus a confirmation email is the right balance. Use the pattern builder above to assemble it and test it against sample addresses.
What do regex flags like g, i, and m mean?
Flags modify how the whole pattern matches: g (global) finds all matches instead of stopping at the first, i (ignore case) makes the match case-insensitive, m (multiline) makes ^ and $ match at line boundaries, and s (dotall) lets . match newlines. Combining them, e.g. /pattern/gi, is common when processing whole documents.
How do I match a date like 2026-09-15 in regex?
For the ISO format YYYY-MM-DD use ^\d{4}-\d{2}-\d{2}$. To also reject impossible months or days, use ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$, which restricts the month to 01-12 and the day to 01-31. True calendar validation (leap years, 30-day months) is best left to a date library after the regex pre-filter.

Related Tools