Tip: Paste any of these patterns into ByteBox's Online Regex Tester to see live matches highlighted in real time.
1. Email Address Validation
/^[\\w.-]+@[\\w.-]+\\.\\w{2,}$/
Validates basic email format. The pattern checks for a local part (word chars, dots, hyphens), an @ symbol, a domain name, and a TLD of at least 2 characters. For RFC 5322 compliant validation, a much longer pattern is needed, but this covers 99% of real-world use cases.
2. URL Matching
/https?:\\/\\/[\\w.-]+\\.\\w{2,}\\/?/
Matches HTTP and HTTPS URLs. The pattern captures the protocol, domain, and optional trailing slash. Works for most common URLs. For more thorough URL parsing (including query params and ports), extend with ([\\w\\-._~:/?#\\[\\]@!$&'()*+,;=]*)?.
3. US Phone Number
/^\\(?\\d{3}\\)?[-.\\s]?\\d{3}[-.\\s]?\\d{4}$/
Matches US phone numbers in formats like (555) 123-4567, 555-123-4567, and 555.123.4567. The optional parentheses, separators, and area code grouping make it flexible for most common input patterns.
4. Date (YYYY-MM-DD)
/^\\d{4}-\\d{2}-\\d{2}$/
Matches dates in ISO 8601 format. For basic validation this is enough. To validate the date exists (e.g., Feb 29 in non-leap years), you'd need to parse the captured groups and check against a calendar — regex alone can't do that.
5. IPv4 Address
/^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$/
Matches four groups of 1-3 digits separated by dots. For stricter validation (each octet 0-255), use: /^(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$/.
6. Hex Color Code
/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/
Matches 3-digit and 6-digit hex color codes with the leading #, like #fff, #000, #ff6600. Case-insensitive match allows both uppercase and lowercase.
7. Strong Password Validation
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[!@#$%^&*]).{8,}$/
Enforces at least one lowercase, one uppercase, one digit, one special character, and minimum 8 characters. The lookaheads ((?=...)) check each condition without consuming characters, so the order doesn't matter.
8. Slug (URL-friendly)
/^[a-z0-9]+(?:-[a-z0-9]+)*$/
Matches URL slugs like my-blog-post-title. Allows lowercase letters, numbers, and hyphens, but prevents leading/trailing/consecutive hyphens.
9. Extract All Hashtags
/#\\w+/g
With the global flag, this extracts every hashtag from text (e.g., #programming, #javascript). The word characters following # can include underscores but not hyphens, matching real-world hashtag conventions.
10. HTML Tag Stripping
/<[^>]*>/g
Removes all HTML tags from a string. Use with caution — this is a simple regex that doesn't handle edge cases like HTML comments or script/style tags. For production sanitization, use a proper HTML parser.
Test These Patterns Live
Copy any pattern above and paste it into ByteBox's Online Regex Tester. The tool shows live matches highlighted in color, supports all JavaScript regex flags (g, i, m, s, u, y), and runs 100% in your browser — no data leaves your machine.
Related Tools
Once you've built your regex, you might need to format JSON with the extracted data, or use the Text Diff Checker to compare strings before and after regex transformations.
All ByteBox tools run 100% client-side. No data is ever uploaded to our servers.