Regex Library
Browse a curated collection of common regex patterns for email, UUID, IP, URL, and more
What is the Regex Library?
The Regex Library is a curated collection of production-ready regular expressions for common validation tasks. Each pattern has been tested against typical inputs and includes clear documentation so you can understand what it matches before copying it into your project.
How to Use
- Browse the collection or use the search field to find a pattern
- Filter by category (Web, Network, Identifiers, Formatting) using the toolbar buttons
- Click on a pattern card to expand details, explanation, and examples
- Use the copy button to copy the pattern string to your clipboard
- For deeper analysis of any pattern, use the Regex Explainer
Common Use Cases
- Form validation — Validate email addresses, URLs, and domains before submission
- Data extraction — Extract UUIDs, IPs, or tokens from log files
- Input sanitization — Verify format compliance for hex colors, slugs, and MAC addresses
- API development — Validate JWT structure and URL parameters in middleware
Example: Email Validation
The email pattern ^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$
matches standard email formats. It checks for a local part with common characters, an @ symbol,
a domain with valid labels, and a TLD of at least two letters. For production systems handling
edge cases defined in RFC 5322, combine with additional validation logic.
Example: UUID v4 Detection
UUID v4 identifiers follow a strict format: 8-4-4-4-12 hex digits with version (4) and variant bits (8, 9, a, or b) in specific positions. The pattern in this library validates the full structure, rejecting malformed or non-v4 UUIDs.
Privacy and Security
The Regex Library is entirely static. No data is sent to any server. Pattern matching, if used, runs locally via JavaScript's built-in RegExp engine. Your data never leaves your browser.
Frequently Asked Questions
What is the Regex Library?
The Regex Library is a curated collection of common regular expression patterns used in software development. It includes patterns for email addresses, UUIDs, IPv4 and IPv6 addresses, URLs, domains, slugs, hex color codes, MAC addresses, and JWT tokens. Each pattern comes with an explanation, valid and invalid examples, and copy functionality.
How do I use a pattern from the library?
Browse or search the collection to find the pattern you need. Each entry shows the regex pattern string, a description of what it matches, a detailed explanation of how it works, and examples of valid and invalid inputs. Click the copy button to copy the pattern to your clipboard for use in your code.
Are these patterns suitable for production use?
These patterns cover the most common formats and are good starting points for validation. However, some formats (like email) have edge cases defined in RFCs that a single regex cannot fully cover. For critical production validation, consider combining regex with additional logic or using dedicated validation libraries.
What is the difference between the Regex Library and the Regex Explainer?
The Regex Library provides a pre-built collection of common patterns you can browse and copy. The Regex Explainer takes any regex you provide and breaks it down into fragments, explaining each part. Use the Library to find patterns, and the Explainer to understand patterns you encounter.
Can I test a pattern against my own input?
Yes. Each pattern in the library includes valid and invalid examples so you can see what it matches. To test against your own text, you can use the Regex Tester tool and paste the pattern from the library along with your test string.
Why does the IPv6 pattern only match full-form addresses?
The IPv6 pattern matches the fully expanded form (eight groups of four hex digits). Shortened forms using :: (double colon) require more complex regex or a multi-step parser. The full-form pattern is simpler and avoids ambiguity in matching.
Is my data sent to a server?
No. The Regex Library is a static collection rendered in your browser. No data is sent to any server. If you use the test functionality, all matching is performed locally using JavaScript's built-in RegExp engine.
What categories are available?
Patterns are organized into four categories: Identifiers (UUID, JWT), Network (IPv4, IPv6, MAC address), Web (email, URL, domain, slug), and Formatting (hex color). You can filter by category or search by name and description.