Generated Regex
Your latest result appears here before the builder.
Generator Controls
Anchors and boundaries
Flags
Visual Pattern Builder
Add reusable blocks and reorder them.
Password Regex Builder
Live Regex Tester
| # | Matched value | Start | End | Groups |
|---|---|---|---|---|
| No matches yet. | ||||
Replace Preview
Regex Explanation
Generate a pattern to see a token-by-token explanation.
Performance and Safety Checks
Code Output
Escape Utilities
Import and Export Configuration
Recent Patterns and Favorites
Recent
Favorites
Formula used
The generator joins anchors groups character classes quantifiers and flags. Each selected rule becomes one regex fragment. Fragments are combined in their displayed order.
How to use this calculator
- Choose a preset or describe your matching goal.
- Adjust anchors flags length rules and advanced groups.
- Generate the expression and review the validation message.
- Paste sample text into the live testing area.
- Inspect matches groups explanations warnings and code output.
- Export the finished regex or save it locally.
Example data table
| Task | Example input | Regex |
|---|---|---|
| Digits only | 12345 | ^\d+$ |
| Letters only | Hello | ^[A-Za-z]+$ |
| Username | john_123 | ^[A-Za-z0-9_]+$ |
| Hex color | #FFAA22 | ^#[A-Fa-f0-9]{6}$ |
Regex Reference and Guidance
What is a regular expression?
A regular expression describes text patterns. It can find validate split or replace matching text.
Character classes
Classes define allowed characters. Common forms include \d \w \s and custom brackets.
Quantifiers
Quantifiers control repetition. Use * + ? or bounded forms such as {2,5}.
Anchors
Anchors control position. The caret targets starts and the dollar sign targets ends.
Groups
Groups capture submatches or organize alternatives. Non-capturing groups avoid unnecessary capture results.
Lookarounds
Lookarounds test nearby text without consuming it. Browser support differs for some lookbehind patterns.
Flags
Flags change matching behavior. Supported flags differ across languages and regex engines.
Escaping
Special regex characters need escaping when treated literally. The escape utility handles common characters.
Limitations
Regex validates structure rather than meaning. Complex nested data usually needs a dedicated parser.
Security
Ambiguous nested repetition can cause excessive backtracking. Test untrusted patterns before production use.
Use focused patterns and test representative data before deployment. Small expressions are easier to review and maintain. Engine differences can change supported syntax and behavior. Prefer clear boundaries when validating complete user input. Keep patterns simple when processing untrusted text at scale.