If you've ever opened a regex tester online and stared at a blank screen, you're not alone. These 10 patterns cover the validation, cleanup, and extraction tasks you'll actually hit in production. Paste any of them into the Regex Tester to try them right now.
10 Patterns That Cover 90% of Use Cases
1. Email
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
Catches standard email addresses in signup and contact forms. Won't reject every edge case, but it stops obvious junk.
2. URL
https?://[^\s]+
Finds raw URLs in plain text, chat exports, or logs. Stops at whitespace, which catches most real-world links. Use URL Encode/Decode to clean encoded characters afterward.
Use it when: extracting links from unstructured text.
3. IP Address (v4)
\b(?:\d{1,3}\.){3}\d{1,3}\b
Pulls IPv4 addresses from server logs or config files. The \b word boundaries prevent partial matches inside longer numbers.
Use it when: parsing access logs or network output.
4. Date (YYYY-MM-DD)
\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])
Validates ISO 8601 dates in API responses or CSV imports. Rejects invalid values like month 13 or day 00.
Use it when: validating date fields in APIs or CSV data.
5. Phone Number
(?:\+?\d{1,3}[\s-.])?(?:\(?\d{3}\)?[\s-.])\d{3}[\s-.]\d{4}
Accepts US and international formats with optional country code. Handles spaces, dashes, dots, and parentheses.
Use it when: validating a phone field that accepts multiple formats.
6. Hex Color
#(?:[0-9a-fA-F]{3}){1,2}\b
Matches shorthand (#fff) and full (#10B981) CSS hex colors.
Use it when: extracting color values from CSS or design tokens.
7. HTML Tag
<\/?[a-z][\w-]*(?:\s[^>]*)?\/?>
Strips or extracts HTML tags from a snippet. Use the Diff Checker to compare text before and after stripping.
Use it when: sanitizing user content or extracting raw text from markup.
8. Digits Only
^\d+$
Checks that an entire string is numbers — nothing else. The ^ and $ anchors are key here.
Use it when: validating numeric IDs, pin codes, or zip codes.
9. Trailing Whitespace
\s+$
Removes invisible whitespace at the end of lines. Run it before feeding text to the JSON Validator — trailing spaces break parsing more often than you'd expect.
Use it when: cleaning up pasted text or CSV rows before storage.
10. Duplicate Words
\b(\w+)\s+\1\b
Catches repeated words like "the the" in prose. The \1 is a back-reference to the first captured group.
Use it when: proofreading generated text or user-submitted content.
Flags That Change Everything
The pattern is only half the story — flags control how the engine applies it.
g (global) finds every match, not just the first. i (case-insensitive) makes email and URL patterns more forgiving.
m (multiline) lets ^ and $ match each line. s (dotAll) makes . match newlines too.
Most regex tester online tools let you toggle flags with one click. Try different combos in the Regex Tester to see what changes.
FAQ
What is the best way to test regex patterns online?
Paste your pattern and sample text into any regex tester. Look for real-time highlighting and flag toggles. The SnipKit Regex Tester has both — no sign-up needed.
Are regex patterns the same in JavaScript and Python?
Core syntax — character classes, quantifiers, groups — is the same. JS uses /pattern/flags literals while Python uses the re module. The 10 patterns in this article work in both languages.
How do I match across multiple lines?
Add the m flag so ^ and $ match line boundaries instead of string boundaries. If you also need . to match newlines, add the s flag alongside m.
Try Them Now
These 10 patterns cover most everyday validation and cleanup work. Bookmark this page and test any of them in the free regex tester online.
