|
| 1 | +# Quick Pattern Reference |
| 2 | + |
| 3 | +A handy reference for common regex patterns to use with Data::Random::String::Matches. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Numbers](#numbers) |
| 8 | +- [Letters](#letters) |
| 9 | +- [Mixed Alphanumeric](#mixed-alphanumeric) |
| 10 | +- [Identifiers](#identifiers) |
| 11 | +- [Contact Information](#contact-information) |
| 12 | +- [Financial](#financial) |
| 13 | +- [Passwords](#passwords) |
| 14 | +- [Codes & References](#codes--references) |
| 15 | +- [Web & URLs](#web--urls) |
| 16 | +- [Technical](#technical) |
| 17 | +- [Dates & Times](#dates--times) |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Numbers |
| 22 | + |
| 23 | +| Pattern | Description | Example Output | |
| 24 | +|---------|-------------|----------------| |
| 25 | +| `\d{4}` | 4-digit number | 1234 | |
| 26 | +| `\d{6}` | 6-digit number | 123456 | |
| 27 | +| `[1-9]\d{3}` | 4-digit, no leading zero | 5432 | |
| 28 | +| `\d{3}-\d{3}-\d{4}` | Phone format | 555-123-4567 | |
| 29 | +| `\d{5}` | ZIP code | 12345 | |
| 30 | +| `\d{5}-\d{4}` | ZIP+4 | 12345-6789 | |
| 31 | + |
| 32 | +## Letters |
| 33 | + |
| 34 | +| Pattern | Description | Example Output | |
| 35 | +|---------|-------------|----------------| |
| 36 | +| `[A-Z]{3}` | 3 uppercase letters | ABC | |
| 37 | +| `[a-z]{5}` | 5 lowercase letters | hello | |
| 38 | +| `[A-Z][a-z]{4}` | Title case word | Hello | |
| 39 | +| `[a-z]{3,8}` | 3-8 lowercase letters | word | |
| 40 | + |
| 41 | +## Mixed Alphanumeric |
| 42 | + |
| 43 | +| Pattern | Description | Example Output | |
| 44 | +|---------|-------------|----------------| |
| 45 | +| `[A-Za-z0-9]{8}` | 8 mixed chars | aB3cD9eF | |
| 46 | +| `[A-Z0-9]{6}` | 6 uppercase + digits | A1B2C3 | |
| 47 | +| `[A-Z]{3}\d{4}` | 3 letters + 4 digits | ABC1234 | |
| 48 | +| `\w{10}` | 10 word chars | aB3_cD9eF_ | |
| 49 | + |
| 50 | +## Identifiers |
| 51 | + |
| 52 | +| Pattern | Description | Example Output | |
| 53 | +|---------|-------------|----------------| |
| 54 | +| `AIza[0-9A-Za-z_-]{35}` | Google API key style | AIzaSyB1c2D3e4F5g6H7i8J9k0L1m2N3o4P5 | |
| 55 | +| `[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}` | UUID v4 | 550e8400-e29b-41d4-a716-446655440000 | |
| 56 | +| `[0-9a-f]{7}` | Git short hash | a1b2c3d | |
| 57 | +| `[A-Z]{3}\d{10}` | Database ID | ABC1234567890 | |
| 58 | +| `[A-Za-z0-9]{32}` | Session token | aB3cD9eFgH1iJ2kL3mN4oP5qR6sT7uV8 | |
| 59 | + |
| 60 | +## Contact Information |
| 61 | + |
| 62 | +| Pattern | Description | Example Output | |
| 63 | +|---------|-------------|----------------| |
| 64 | +| `\d{3}-\d{3}-\d{4}` | US Phone | 555-123-4567 | |
| 65 | +| `\+1-\d{3}-\d{3}-\d{4}` | US Phone (intl) | +1-555-123-4567 | |
| 66 | +| `\(\d{3}\) \d{3}-\d{4}` | US Phone (formatted) | (555) 123-4567 | |
| 67 | +| `[a-z]{5,10}@[a-z]{5,10}\.com` | Simple email | hello@world.com | |
| 68 | +| `[a-z]{5,10}@(gmail\|yahoo\|hotmail)\.com` | Email with domains | user@gmail.com | |
| 69 | +| `\d{5}` | US ZIP | 12345 | |
| 70 | +| `[A-Z]{2} \d[A-Z] \d[A-Z]\d` | Canadian postal | K1A 0B1 | |
| 71 | + |
| 72 | +## Financial |
| 73 | + |
| 74 | +| Pattern | Description | Example Output | |
| 75 | +|---------|-------------|----------------| |
| 76 | +| `4\d{15}` | Visa test card | 4123456789012345 | |
| 77 | +| `5[1-5]\d{14}` | Mastercard test | 5412345678901234 | |
| 78 | +| `\d{4}-\d{4}-\d{4}-\d{4}` | Card formatted | 1234-5678-9012-3456 | |
| 79 | +| `\d{3}` | CVV | 123 | |
| 80 | +| `\d{10,12}` | Bank account | 1234567890 | |
| 81 | +| `TXN[A-Z0-9]{12}` | Transaction ID | TXNA1B2C3D4E5F6 | |
| 82 | + |
| 83 | +## Passwords |
| 84 | + |
| 85 | +| Pattern | Description | Example Output | |
| 86 | +|---------|-------------|----------------| |
| 87 | +| `[A-Za-z0-9]{12}` | Simple 12-char | aB3cD9eFgH1i | |
| 88 | +| `[A-Za-z0-9!@#$%^&*]{16}` | Strong 16-char | aB3!cD9@eFgH#1iJ | |
| 89 | +| `[A-Z][a-z]{3}\d{4}` | Temp password | Pass1234 | |
| 90 | +| `[a-z]{4,8}-[a-z]{4,8}-[a-z]{4,8}` | Passphrase | word-another-third | |
| 91 | +| `[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}` | Recovery code | A1B2-C3D4-E5F6 | |
| 92 | + |
| 93 | +## Codes & References |
| 94 | + |
| 95 | +| Pattern | Description | Example Output | |
| 96 | +|---------|-------------|----------------| |
| 97 | +| `ORD-\d{8}` | Order number | ORD-12345678 | |
| 98 | +| `INV-\d{4}-[A-Z]{3}` | Invoice number | INV-2024-ABC | |
| 99 | +| `(SAVE\|DEAL\|SALE)\d{2}[A-Z]{3}` | Coupon code | SAVE10ABC | |
| 100 | +| `[A-Z]{2}-\d{4}-[A-Z]{2}` | Product SKU | AB-1234-CD | |
| 101 | +| `SN[A-Z0-9]{10}` | Serial number | SNA1B2C3D4E5 | |
| 102 | +| `CONF-[A-Z0-9]{6}` | Confirmation | CONF-A1B2C3 | |
| 103 | + |
| 104 | +## Web & URLs |
| 105 | + |
| 106 | +| Pattern | Description | Example Output | |
| 107 | +|---------|-------------|----------------| |
| 108 | +| `[a-z]{5,10}\.example\.com` | Subdomain | hello.example.com | |
| 109 | +| `[A-Za-z0-9]{6}` | Short URL code | aB3cD9 | |
| 110 | +| `[a-z]{3,8}\d{2,4}` | Username | user123 | |
| 111 | +| `[a-z]{4,8}-[a-z]{4,8}` | URL slug | some-slug | |
| 112 | +| `[a-z0-9]{8,16}` | Username (strict) | user1234 | |
| 113 | + |
| 114 | +## Technical |
| 115 | + |
| 116 | +| Pattern | Description | Example Output | |
| 117 | +|---------|-------------|----------------| |
| 118 | +| `\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}` | IPv4 address | 192.168.1.1 | |
| 119 | +| `[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}` | MAC address | 00:1A:2B:3C:4D:5E | |
| 120 | +| `\d{1,2}\.\d{1,2}\.\d{1,3}` | Version number | 1.2.345 | |
| 121 | +| `#[0-9A-F]{6}` | Hex color | #FF5733 | |
| 122 | +| `[0-9a-f]{32}` | MD5 hash | 5d41402abc4b2a76b9719d911017c592 | |
| 123 | +| `[0-9a-f]{40}` | SHA-1 hash | 356a192b7913b04c54574d18c28d46e6395428ab | |
| 124 | + |
| 125 | +## Dates & Times |
| 126 | + |
| 127 | +| Pattern | Description | Example Output | |
| 128 | +|---------|-------------|----------------| |
| 129 | +| `20\d{2}-(0[1-9]\|1[0-2])-(0[1-9]\|[12]\d\|3[01])` | Date YYYY-MM-DD | 2024-03-15 | |
| 130 | +| `(0[1-9]\|1[0-2])/([0-2]\d\|3[01])/\d{4}` | Date MM/DD/YYYY | 03/15/2024 | |
| 131 | +| `([01]\d\|2[0-3]):[0-5]\d` | Time HH:MM | 14:30 | |
| 132 | +| `([01]\d\|2[0-3]):[ |
0 commit comments