Regular expressions are the fastest way to find sensitive data in text: emails, phone numbers, API keys, card numbers, and more. Whether you're scrubbing logs, validating input, or blurring data before a screen share, a good regex does the heavy lifting.
Below is a copy-paste cheat sheet of regex patterns for common sensitive data, with notes on what each one matches and where it can go wrong.
Regex for Personal Data
Email address regex
[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}
Matches most real-world email addresses. It's deliberately practical rather than fully RFC-compliant, which is what you want for detection.
Phone number regex (US format)
(?:\+?1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}
Matches formats like 555-123-4567, (555) 123-4567, and +1 555 123 4567. International formats vary widely, so you'll need separate patterns per country.
US Social Security Number (SSN) regex
\b\d{3}-\d{2}-\d{4}\b
Matches the standard dashed format. It will also match other numbers shaped like 123-45-6789, so expect occasional false positives.
Regex for Financial Data
Credit card number regex
\b(?:\d[ -]?){13,19}\b
Matches 13 to 19 digits with optional spaces or dashes. Long order numbers and IDs can match too, so a Luhn checksum is the proper way to confirm a real card number.
IBAN regex
\b[A-Z]{2}\d{2}[A-Z0-9]{11,30}\b
Matches the general IBAN shape: a two-letter country code, two check digits, and the account part.
Money amount regex
[$€£]\s?\d{1,3}(?:,\d{3})*(?:\.\d{2})?
Matches amounts like $1,250.00, €99, and £4,500.50. Handy for hiding revenue in dashboards.
Regex for API Keys and Secrets
Many providers use recognizable prefixes, which makes their keys easy to detect:
AWS access key ID
\bAKIA[0-9A-Z]{16}\b
GitHub personal access token
\bgh[pousr]_[A-Za-z0-9]{36,}\b
Stripe secret key
\bsk_(?:live|test)_[A-Za-z0-9]{24,}\b
Google API key
\bAIza[0-9A-Za-z_-]{35}\b
JSON Web Token (JWT)
\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b
Key formats change over time, so check your provider's current documentation if a pattern stops matching.
Regex for Crypto Wallets
Ethereum address
\b0x[a-fA-F0-9]{40}\b
Bitcoin address (legacy format)
\b[13][a-km-zA-HJ-NP-Z1-9]{25,34}\b
Newer Bitcoin addresses starting with bc1 use a different format and need their own pattern.
Write Custom Regex for Your Own Data
Your company probably has identifiers no generic pattern knows about, like customer IDs, ticket numbers, or project codes. The recipe is simple: find the fixed prefix, then describe what follows it.
\bCUST-\d{6}\b
This matches IDs like CUST-482913. Swap in your own prefix and digit count.
Tips for Better Regex Detection
- Use word boundaries (
\b) so you don't match inside longer strings. - Test on realistic data. Check for both misses and false positives.
- Never paste real secrets into online regex testers. Use fake examples instead.
- Be specific. Overly broad patterns blur or flag things you didn't intend.
- Rotate any real key that has ever appeared on screen or in a log.
Use These Regex Patterns to Blur Data in Your Browser
If you share your screen or record demos, you can put these patterns to work without writing code. BlurKit is a Chrome extension with a regex blur list: add your own patterns and any matching text on the page is blurred before it's shared or recorded. It also auto-detects common data like emails, phone numbers, SSNs, credit cards, secret keys, IBANs, money amounts, crypto wallets, dates of birth, and addresses, so you only need regex for the custom cases. Everything runs 100% locally, and nothing leaves your browser.
Frequently Asked Questions
What is the best regex to detect an email address?
For detection, [A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,} works well for the vast majority of addresses.
How do I detect API keys with regex?
Most providers use a fixed prefix, such as AKIA for AWS or sk_live_ for Stripe, followed by a set number of characters. Match the prefix, then the length and character set.
Can regex validate a credit card number?
Regex can find card-shaped numbers, but only a Luhn checksum confirms one is valid.
How can I blur text that matches a regex in my browser?
Use an extension with a regex blur list, such as BlurKit. Add a pattern and every match on the page is blurred automatically.
How much does BlurKit cost?
BlurKit costs $9.99 as a one-time payment for lifetime access, with no subscription.
Turn Regex into Instant Privacy
Don't just detect sensitive data, hide it. Get BlurKit for just $9.99 (one-time payment) and blur anything that matches your patterns for every screen share and recording.
Auto-blur 11 types of PII during screen sharing.
Automatically detect and blur sensitive data in real-time. Works with Zoom, Meet, Teams, and every screen sharing tool. 100% local processing.
Get BlurKit — $9.99 LifetimePart of the BlurKit team, helping people protect their privacy during screen sharing and presentations.