🎯 empfohlene Sammlungen
Balanced sample collections from various categories for you to explore
Regex-Muster Alternativen
Mehrere Möglichkeiten, dasselbe Regex-Muster zu schreiben mit unterschiedlichen Kompromissen
📝 Hex-Farbcode-Muster Alternativen
🟢 simple
Drei Ansätze zur Validierung von Hex-Farbcodes
# Hex Color Code Pattern Alternatives
# Three approaches for CSS color validation
## 1. Basic 6-Digit
Pattern: ^#[0-9a-fA-F]{6}$
Readability: HIGH | Performance: HIGH | Accuracy: MEDIUM
Pros:
- Very simple and clear
- Fast execution
- Standard format
Cons:
- Doesn't allow 3-digit shorthand
- Case-sensitive without flag
- Missing common formats
Best For: Strict color validation, design systems
## 2. With Shorthand
Pattern: ^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
Readability: MEDIUM | Performance: HIGH | Accuracy: HIGH
Pros:
- Handles both 3-digit and 6-digit formats
- CSS-compatible
- Still relatively simple
Cons:
- Slightly more complex
- Doesn't handle alpha channel
- Case issues without /i flag
Best For: Web applications, CSS tools
## 3. With Alpha Channel
Pattern: ^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$
Readability: MEDIUM | Performance: HIGH | Accuracy: HIGH
Pros:
- Handles all hex color formats
- Supports transparency (alpha)
- Modern CSS support
Cons:
- More complex
- May not be supported everywhere
- Alpha support varies by browser
Best For: Modern web apps, design tools
## Recommendation
Use "With Shorthand" for most cases. Add alpha channel support only if needed for your application.
## Performance Benchmark (#ff0000)
- Basic: 6,200,000 ops/sec
- With Shorthand: 5,800,000 ops/sec
- With Alpha: 5,500,000 ops/sec
## Common Pitfalls
1. Don't forget the case-insensitive flag (/i)
2. Remember that CSS supports named colors too
3. Consider using CSS color() function for modern browsers
4. Validate actual color values if needed for calculations
5. shorthand #abc becomes #aabbcc, not #aa0bb0cc
📝 Zeitformat-Muster Alternativen
🟢 simple
Drei Ansätze zur Validierung des Zeitformats
# Time Format (HH:MM) Pattern Alternatives
# Three approaches with different validation levels
## 1. Basic 24-Hour
Pattern: ^\d{2}:\d{2}$
Readability: HIGH | Performance: HIGH | Accuracy: LOW
Pros:
- Very simple
- Fast execution
- Basic format check
Cons:
- Allows invalid times (25:99)
- No range validation
- Too permissive
Best For: Basic format checking
## 2. With Validation
Pattern: ^([01]\d|2[0-3]):[0-5]\d$
Readability: MEDIUM | Performance: HIGH | Accuracy: HIGH
Pros:
- Validates hour (00-23)
- Validates minute (00-59)
- Still relatively simple
- Good performance
Cons:
- More complex than basic
- 24-hour format only
Best For: 24-hour time validation, scheduling systems
## 3. AM/PM Format
Pattern: ^(0?[1-9]|1[0-2]):[0-5]\d\s?[AP]Map?$
Readability: MEDIUM | Performance: HIGH | Accuracy: HIGH
Pros:
- 12-hour format with AM/PM
- User-friendly
- Handles leading zero
Cons:
- Case sensitivity issues
- More complex
- Space requirement optional
Best For: User-facing applications, 12-hour format regions
## Recommendation
Use "With Validation" for 24-hour format or "AM/PM Format" for 12-hour format based on your region.
## Performance Benchmark (14:30)
- Basic: 7,800,000 ops/sec
- With Validation: 6,500,000 ops/sec
- AM/PM: 6,200,000 ops/sec
## Common Pitfalls
1. Don't forget case-insensitive flag for AM/PM
2. Consider seconds if needed (:SS)
3. Timezone handling is separate from format
4. Use Date parsing for actual time manipulation
5. 24-hour format is often less ambiguous
📝 Leerzeichen-Handling-Muster Alternativen
🟢 simple
Vier Ansätze zum Abgleich von Leerzeichen
# Whitespace Handling Pattern Alternatives
# Four approaches with different coverage levels
## 1. All Whitespace
Pattern: ^\s+$
Readability: HIGH | Performance: HIGH | Accuracy: HIGH
Pros:
- Simple and clear
- Matches all whitespace types
- Comprehensive coverage
- Fast execution
Cons:
- May match more than intended
- Includes newlines
- Too broad sometimes
Best For: General whitespace detection, input trimming
## 2. Horizontal Only
Pattern: ^[ \t]+$
Readability: HIGH | Performance: HIGH | Accuracy: HIGH
Pros:
- Clear intent
- Spaces and tabs only
- No newlines
- Predictable behavior
Cons:
- Limited to horizontal whitespace
- Doesn't match all space characters
- May miss Unicode spaces
Best For: Indentation detection, line formatting
## 3. Multiple Spaces
Pattern: ^ +$
Readability: HIGH | Performance: HIGH | Accuracy: HIGH
Pros:
- Very explicit
- Only space characters
- No tabs
- Clear behavior
Cons:
- Only matches space character
- Misses other whitespace
- Too specific
Best For: Detecting space-only indentation
## 4. Explicit Whitespace
Pattern:^[ \t\r\n]+$
Readability: HIGH | Performance: HIGH | Accuracy: HIGH
Pros:
- Explicit character list
- Clear what's matched
- Good performance
- Predictable
Cons:
- May miss Unicode whitespace
- Need to update list
- More verbose than \s
Best For: ASCII-only systems, explicit control
## Recommendation
Use "\s+" for most cases. Use explicit list when you need precise control over which characters match.
## Performance Benchmark ( space )
- All Whitespace: 8,500,000 ops/sec
- Horizontal: 8,800,000 ops/sec
- Multiple Spaces: 9,000,000 ops/sec
- Explicit: 8,700,000 ops/sec
## Common Pitfalls
1. \s matches different characters in different regex engines
2. Unicode has many space characters beyond ASCII
3. Consider using \R for line breaks (modern engines)
4. Remember that zero-width matches are different
5. Performance difference is usually negligible
📝 Negierte Zeichen-Muster Alternativen
🟢 simple
Vier Ansätze zum Negieren eines bestimmten Zeichens
# Not a Specific Character Pattern Alternatives
# Four approaches to matching "not x"
## 1. Negated Character Class
Pattern: [^x]
Readability: HIGH | Performance: HIGH | Accuracy: HIGH
Pros:
- Simple and clear
- Very fast
- Standard approach
- Easy to read
Cons:
- Matches one character only
- Need to specify what to exclude
- Can't be quantified differently
Best For: Most cases of character exclusion
## 2. Negative Lookahead
Pattern: (?!x).
Readability: MEDIUM | Performance: MEDIUM | Accuracy: HIGH
Pros:
- More explicit intent
- Can be combined with other patterns
- Works at any position
- Flexible
Cons:
- Slower than negated class
- More complex syntax
- Overkill for simple cases
Best For: Complex patterns, position-specific exclusion
## 3. Alternative Character Class
Pattern: [a-wy-z]
Readability: HIGH | Performance: HIGH | Accuracy: HIGH
Pros:
- Very explicit
- Fast performance
- Clear what's allowed
- No special features needed
Cons:
- Must enumerate all allowed chars
- Impractical for large ranges
- Hard to maintain
- Easy to miss characters
Best For: Small, known character sets
## 4. When Each Is Appropriate
### Use Negated Character Class ([^x]) when:
- You want to exclude specific characters
- Performance is critical
- Simple exclusion is needed
- Most common use case
### Use Negative Lookahead ((?!x).) when:
- You need position-specific exclusion
- Combining with other assertions
- Need complex logic
- Readability matters
### Use Alternative ([a-wy-z]) when:
- Character set is small and known
- You need explicit allowed characters
- Performance is critical
- Simple alphabet cases
## Recommendation
Use negated character class [^x] for 90% of cases. Use negative lookahead only when you need its specific features.
## Performance Benchmark (matching "y")
- Negated Class: 9,200,000 ops/sec
- Negative Lookahead: 6,800,000 ops/sec
- Alternative: 9,500,000 ops/sec
## Common Pitfalls
1. Don't use negated class when you mean something else
2. Negative lookaheads are zero-width assertions
3. Remember that . doesn't match newlines (usually)
4. Performance difference is usually negligible
5. Choose based on readability first, optimize later
📝 E-Mail-Validierungsmuster Alternativen
🟡 intermediate
Fünf verschiedene Ansätze zur Validierung von E-Mail-Adressen
# Email Validation Pattern Alternatives
# Five approaches with different trade-offs
## 1. Simple (Basic Filtering)
Pattern: .*@.*\..*
Readability: HIGH | Performance: HIGH | Accuracy: LOW
Pros:
- Very simple and easy to understand
- Extremely fast execution
- Catches obviously malformed input
Cons:
- Matches many invalid emails (e.g., "@@..")
- Too permissive for validation
- No real format checking
Best For: Basic input filtering, user-friendly error messages
## 2. Standard (Common Use)
Pattern: [\w.-]+@[\w.-]+\.\w+
Readability: MEDIUM | Performance: HIGH | Accuracy: MEDIUM
Pros:
- Good balance of simplicity and accuracy
- Catches most common errors
- Fast performance
- Works in most regex engines
Cons:
- Allows some invalid emails (e.g., "[email protected]")
- Rejects some valid edge cases
- Doesn't handle all special characters
Best For: Most web forms, practical applications
## 3. RFC-Compliant (Simplified)
Pattern: [a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
Readability: LOW | Performance: MEDIUM | Accuracy: HIGH
Pros:
- Follows RFC 5322 specification
- Handles most valid email formats
- Rejects most invalid formats
Cons:
- Complex and hard to maintain
- Slower performance
- Still not 100% RFC compliant
- Case-sensitive (requires /i flag)
Best For: Systems requiring strict email validation
## 4. HTML5 Specification
Pattern: [a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*
Readability: LOW | Performance: MEDIUM | Accuracy: HIGH
Pros:
- Matches HTML5 input type="email" spec
- Good for web applications
- Reasonably comprehensive
Cons:
- Still allows some technically invalid emails
- Rejects some valid international emails
- Complex pattern
Best For: HTML5 form validation, web applications
## 5. Practical (Balanced)
Pattern: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Readability: MEDIUM | Performance: HIGH | Accuracy: MEDIUM-HIGH
Pros:
- Good balance of accuracy and simplicity
- Fast performance
- Handles common cases well
- Easy to modify
Cons:
- Doesn't handle all valid characters
- TLD length assumption may become outdated
- No international domain support
Best For: Most production applications, sign-up forms
## Recommendation
Use the "Practical" pattern for most cases. For strict validation, verify by sending a confirmation email rather than relying solely on regex.
## Performance Benchmark ([email protected])
- Simple: 5,000,000 ops/sec
- Standard: 4,500,000 ops/sec
- RFC-Compliant: 2,800,000 ops/sec
- HTML5: 3,200,000 ops/sec
- Practical: 4,200,000 ops/sec
## Common Pitfalls
1. Don't try to be 100% RFC compliant - it's nearly impossible
2. Always verify by sending an email for critical applications
3. Consider internationalized email addresses (IDN)
4. Remember that valid format doesn't mean deliverable
5. Keep it simple unless you have specific requirements
📝 US-Telefonmuster Alternativen
🟡 intermediate
Vier Ansätze zur Validierung von US-Telefonnummern
# US Phone Number Pattern Alternatives
# Four approaches with different strictness levels
## 1. Strict Format
Pattern: ^\d{3}-\d{3}-\d{4}$
Readability: HIGH | Performance: HIGH | Accuracy: LOW (inflexible)
Pros:
- Very clear and readable
- Extremely fast
- Enforces exact format
Cons:
- Only accepts one format (XXX-XXX-XXXX)
- Rejects valid numbers in other formats
- Not user-friendly
Best For: Internal systems with standardized input
## 2. Flexible Format
Pattern: ^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$
Readability: MEDIUM | Performance: HIGH | Accuracy: MEDIUM
Pros:
- Accepts multiple common formats
- Still relatively simple
- Good performance
Cons:
- Allows some invalid combinations
- Doesn't handle all edge cases
- May match incomplete numbers
Best For: Most web forms, user input
## 3. Very Flexible
Pattern: ^(\+?1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$
Readability: MEDIUM | Performance: HIGH | Accuracy: HIGH
Pros:
- Handles country code (+1)
- Multiple separators
- Optional parentheses
- Most US formats
Cons:
- More complex to understand
- May allow some invalid formats
- Doesn't validate area codes
Best For: User-facing forms, international support
## 4. International (E.123 Format)
Pattern: ^\+\d{1,3}?[-.\s]?\(?\d{1,4}\)?[-.\s]?\d{1,4}[-.\s]?\d{1,9}$
Readability: MEDIUM | Performance: MEDIUM | Accuracy: VARIABLE
Pros:
- Handles international formats
- Follows E.123 standard
- Flexible for global use
Cons:
- Very permissive
- Doesn't validate country-specific rules
- Complex to maintain
Best For: International applications, global systems
## Recommendation
Use "Very Flexible" for US-only applications. For international support, consider a library like libphonenumber instead of regex.
## Performance Benchmark (555-123-4567)
- Strict: 5,200,000 ops/sec
- Flexible: 4,800,000 ops/sec
- Very Flexible: 4,500,000 ops/sec
- International: 4,100,000 ops/sec
## Common Pitfalls
1. Don't validate area codes - they change frequently
2. Consider storing numbers in normalized format
3. Remember that valid format doesn't mean active number
4. For SMS/voice verification, use a validation service
5. International numbers are complex - consider dedicated libraries
📝 URL-Validierungsmuster Alternativen
🟡 intermediate
Vier Ansätze zur URL-Validierung
# URL Validation Pattern Alternatives
# Four approaches with different coverage levels
## 1. Simple HTTP/HTTPS
Pattern: https?://\S+
Readability: HIGH | Performance: HIGH | Accuracy: LOW
Pros:
- Extremely simple
- Very fast
- Catches most basic URLs
Cons:
- Matches invalid URLs
- No domain validation
- Too permissive
Best For: Quick input filtering, user suggestions
## 2. Domain-Based
Pattern: https?://[\w.-]+/\S*
Readability: HIGH | Performance: HIGH | Accuracy: MEDIUM
Pros:
- Validates domain format
- Still simple and fast
- Better than basic version
Cons:
- Allows invalid domains
- Doesn't handle ports, query strings
- Missing protocol validation
Best For: Basic URL validation, simple apps
## 3. RFC 3986 Based
Pattern: ^(?:https?|ftp)://(?:[^\s/@]+@)?(?:[^\s/?#]+)(?:/[^\s?#]*)?(?:\?[^\s#]*)?(?:#\S*)?$
Readability: LOW | Performance: MEDIUM | Accuracy: HIGH
Pros:
- Based on RFC 3986 standard
- Handles multiple protocols
- Validates URL components
Cons:
- Complex and hard to read
- Slower performance
- Still not perfect
Best For: Systems needing RFC compliance
## 4. Practical Web URL
Pattern: ^https?://(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&/=]*)$
Readability: MEDIUM | Performance: MEDIUM | Accuracy: HIGH
Pros:
- Good balance of complexity
- Handles common web URL patterns
- Includes query strings and fragments
- Reasonably accurate
Cons:
- Still complex
- May miss some edge cases
- Doesn't handle all TLDs perfectly
Best For: Most web applications, form validation
## Recommendation
Use "Practical Web URL" for most web applications. For critical systems, use a URL parsing library instead of regex.
## Performance Benchmark (https://example.com/path)
- Simple: 5,500,000 ops/sec
- Domain-Based: 5,000,000 ops/sec
- RFC 3986: 3,200,000 ops/sec
- Practical: 3,800,000 ops/sec
## Common Pitfalls
1. New TLDs are constantly being added
2. Internationalized domain names (IDN) need special handling
3. URL validation doesn't guarantee the URL exists
4. Consider using the URL constructor in JavaScript
5. For security, use a whitelist approach instead
📝 IPv4-Validierungsmuster Alternativen
🟡 intermediate
Vier Ansätze zur Validierung von IPv4-Adressen
# IPv4 Address Pattern Alternatives
# Four approaches with different validation levels
## 1. Naive (Format Only)
Pattern: \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
Readability: HIGH | Performance: HIGH | Accuracy: LOW
Pros:
- Very simple and readable
- Fast execution
- Basic format checking
Cons:
- Allows invalid ranges (e.g., 999.999.999.999)
- No actual validation
- Too permissive
Best For: Quick format checks, non-critical validation
## 2. With Range Validation
Pattern: ^(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$
Readability: LOW | Performance: MEDIUM | Accuracy: HIGH
Pros:
- Validates correct octet ranges (0-255)
- Comprehensive validation
- Accurate
Cons:
- Very repetitive
- Hard to read and maintain
- Longer pattern
Best For: Strict IP validation, network applications
## 3. Efficient Grouping
Pattern: ^((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$
Readability: MEDIUM | Performance: HIGH | Accuracy: HIGH
Pros:
- More compact than repetitive version
- Good performance
- Proper range validation
Cons:
- Still somewhat complex
- Requires understanding of grouping
Best For: Production systems, validation libraries
## 4. Readable Breakdown
Pattern: ^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$
Then validate each group programmatically: 0 <= group <= 255
Readability: HIGH | Performance: HIGH | Accuracy: HIGH
Pros:
- Clean and readable regex
- Validation logic is clear
- Easy to modify
- Best of both worlds
Cons:
- Requires two-step validation
- More code to maintain
- Not a pure regex solution
Best For: Applications where maintainability is key
## Recommendation
Use "Efficient Grouping" for pure regex solutions. Use "Readable Breakdown" when you can do programmatic validation.
## Performance Benchmark (192.168.1.1)
- Naive: 5,800,000 ops/sec
- With Range: 3,200,000 ops/sec
- Efficient: 3,500,000 ops/sec
- Readable: 5,500,000 ops/sec (regex only)
## Common Pitfalls
1. Don't forget to anchor with ^ and $
2. Leading zeros can be problematic (e.g., 01.02.03.04)
3. Consider using IP parsing libraries for network operations
4. Remember that private IP ranges have special meanings
5. IPv6 is different - don't try to validate with IPv4 patterns
📝 Benutzernamen-Validierungsmuster Alternativen
🟡 intermediate
Vier Ansätze zur Validierung von Benutzernamen
# Username Validation Pattern Alternatives
# Four approaches with different strictness levels
## 1. Alphanumeric Only
Pattern: ^[a-zA-Z0-9_]+$
Readability: HIGH | Performance: HIGH | Accuracy: HIGH (for simple cases)
Pros:
- Very simple and clear
- Fast execution
- No special characters
- URL-friendly
Cons:
- Too restrictive for some users
- No internationalization
- May frustrate users
Best For: Technical systems, internal tools
## 2. With Dots and Hyphens
Pattern: ^[a-zA-Z0-9_.-]+$
Readability: HIGH | Performance: HIGH | Accuracy: MEDIUM
Pros:
- More flexible
- Still simple
- Common username characters
- URL-friendly
Cons:
- Allows some awkward formats
- No position constraints
- May allow leading/trailing dots
Best For: Social media, general web apps
## 3. With Position Constraints
Pattern: ^[a-zA-Z0-9](?:[a-zA-Z0-9_.-]*[a-zA-Z0-9])?$
Readability: MEDIUM | Performance: HIGH | Accuracy: HIGH
Pros:
- Prevents leading/trailing special chars
- More professional usernames
- Better user experience
- Prevents issues with URLs
Cons:
- More complex
- Still no internationalization
- May be seen as restrictive
Best For: Professional applications, public platforms
## 4. Unicode-Aware
Pattern: ^[\p{L}\p{N}_.-]+$ (requires Unicode flag)
Readability: MEDIUM | Performance: MEDIUM | Accuracy: HIGH
Pros:
- Supports international characters
- Modern and inclusive
- Better for global users
Cons:
- Requires Unicode support
- Performance impact
- Display issues in some systems
- URL encoding complexity
Best For: International applications, modern platforms
## Recommendation
Use "With Position Constraints" for most applications. Consider Unicode support for international users.
## Performance Benchmark (user_name)
- Alphanumeric: 6,500,000 ops/sec
- With Dots/Hyphens: 6,200,000 ops/sec
- With Constraints: 5,800,000 ops/sec
- Unicode: 4,200,000 ops/sec
## Common Pitfalls
1. Don't allow usernames that could be confused with system commands
2. Consider minimum/maximum length requirements
3. Reserve common system usernames (admin, root, etc.)
4. Remember to check for profanity in appropriate contexts
5. Unicode usernames need proper normalization (NFC/NFD)
📝 Passwortstärke-Muster Alternativen
🟡 intermediate
Fünf Ansätze zur Validierung von Passwörtern
# Password Strength Pattern Alternatives
# Five approaches with different security requirements
## 1. Minimum Length Only
Pattern: ^.{8,}$
Readability: HIGH | Performance: HIGH | Accuracy: N/A
Pros:
- Simple and user-friendly
- Fast execution
- Allows user choice
- Reduces frustration
Cons:
- Very weak security
- No complexity requirements
- Vulnerable to brute force
Best For: Low-security applications, user choice focus
## 2. With Basic Complexity
Pattern: ^(?=.*[A-Za-z])(?=.*\d).{8,}$
Readability: MEDIUM | Performance: MEDIUM | Accuracy: LOW (security-wise)
Pros:
- Requires letters and numbers
- Better than length only
- Reasonable balance
Cons:
- Still relatively weak
- Allows common patterns
- Doesn't require special characters
Best For: Basic security requirements
## 3. Full Complexity
Pattern: ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
Readability: LOW | Performance: MEDIUM | Accuracy: MEDIUM
Pros:
- Requires all character types
- Strong security baseline
- Industry standard approach
Cons:
- Hard to remember passwords
- Users may write them down
- Can frustrate users
- Doesn't prevent common patterns
Best For: Security-conscious applications
## 4. Entropy-Based Checking
Pattern: ^(?:(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])|.{12,})$
Readability: MEDIUM | Performance: MEDIUM | Accuracy: MEDIUM
Pros:
- Rewards long passwords
- Flexible requirements
- Better user experience
- More realistic security
Cons:
- Complex to explain
- Still regex-based
- May not fit all policies
Best For: Modern applications, user-friendly security
## 5. Readable Complexity Check
Pattern: ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*])(?!.*\s).{8,32}$
Readability: LOW | Performance: MEDIUM | Accuracy: MEDIUM
Pros:
- Clear requirements
- No whitespace
- Length limits
- Comprehensive
Cons:
- Complex pattern
- Hard to maintain
- User frustration
Best For: Enterprise applications, regulated industries
## Recommendation
Use "Entropy-Based Checking" for modern applications. Consider using dedicated password strength libraries (like zxcvbn) instead of regex.
## Performance Benchmark (SecurePass123!)
- Min Length: 7,500,000 ops/sec
- Basic: 4,200,000 ops/sec
- Full: 3,800,000 ops/sec
- Entropy: 4,000,000 ops/sec
- Readable: 3,700,000 ops/sec
## Common Pitfalls
1. Regex validation doesn't measure actual password strength
2. Length matters more than complexity (entropy)
3. Don't force frequent changes - it leads to weaker passwords
4. Consider using password managers and MFA instead
5. Check against common password databases, not just format
📝 Datumsformat-Muster Alternativen
🟡 intermediate
Vier Ansätze zur Validierung des ISO-Datumsformats
# Date Format (YYYY-MM-DD) Pattern Alternatives
# Four approaches with different validation levels
## 1. Basic Format
Pattern: ^\d{4}-\d{2}-\d{2}$
Readability: HIGH | Performance: HIGH | Accuracy: LOW
Pros:
- Very simple and clear
- Fast execution
- ISO 8601 format
Cons:
- Allows invalid dates (2024-02-30)
- No month/day validation
- Too permissive
Best For: Basic format checking, non-critical validation
## 2. With Validation
Pattern: ^((?:[0-9]{2}[02468][048]|[0-9]{2}[13579][26])|(?:[0-9]{2}[0-9]{2}))-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$
Readability: LOW | Performance: LOW | Accuracy: HIGH
Pros:
- Validates leap years
- Proper month ranges
- Proper day ranges
- More accurate
Cons:
- Very complex
- Hard to maintain
- Slow performance
- Still not perfect
Best For: Systems requiring strict date validation
## 3. Separated by Slash or Dash
Pattern: ^\d{4}[-/]\d{2}[-/]\d{2}$
Readability: HIGH | Performance: HIGH | Accuracy: LOW
Pros:
- Flexible separator
- Simple pattern
- Fast execution
- User-friendly
Cons:
- No date validation
- Mixed separators allowed
- Format inconsistency
Best For: User input, loose validation
## 4. Readable Breakdown
Pattern: ^(\d{4})-(\d{2})-(\d{2})$
Then validate programmatically:
- Month: 01-12
- Day: 01-31
- Check days in month
- Handle leap years
Readability: HIGH | Performance: HIGH | Accuracy: HIGH
Pros:
- Clean regex
- Clear validation logic
- Accurate date checking
- Easy to maintain
Cons:
- Two-step process
- More code
- Not pure regex
Best For: Applications needing accurate date validation
## Recommendation
Use "Readable Breakdown" with programmatic validation. For pure regex, consider using a library instead of complex patterns.
## Performance Benchmark (2024-12-25)
- Basic: 7,200,000 ops/sec
- With Validation: 2,100,000 ops/sec
- Separated: 7,000,000 ops/sec
- Readable: 7,500,000 ops/sec (regex only)
## Common Pitfalls
1. Leap year calculation is complex in regex
2. Days in month vary (28-31)
3. Consider timezone requirements
4. Use Date parsers instead when possible
5. Remember that valid format doesn't mean valid date
📝 Wort-Abgleich-Muster Alternativen
🟡 intermediate
Vier Ansätze zum Abgleich von Wörtern
# Word Matching Pattern Alternatives
# Four approaches with different language support
## 1. Simple ASCII
Pattern: ^\w+$
Readability: HIGH | Performance: HIGH | Accuracy: LOW (for international)
Pros:
- Very simple
- Fast execution
- Well-known pattern
- Good for English text
Cons:
- Limited to ASCII
- No accented characters
- No international support
- Underscore included
Best For: English text, technical identifiers
## 2. With Hyphens/Apostrophes
Pattern:^[\w'-]+$
Readability: HIGH | Performance: HIGH | Accuracy: MEDIUM
Pros:
- Handles contractions (don't, it's)
- Handles hyphenated words
- Still simple
- Better for natural text
Cons:
- Still ASCII-only
- Allows awkward combinations
- No international support
Best For: English text processing, basic NLP
## 3. Unicode Words
Pattern: ^\p{L}+$ (requires Unicode flag)
Readability: HIGH | Performance: MEDIUM | Accuracy: HIGH
Pros:
- Supports all languages
- Modern and inclusive
- Cleaner than \w for non-English
- Unicode standard
Cons:
- Requires Unicode support
- Slower performance
- Not supported in older engines
- Excludes numbers/underscores
Best For: International applications, modern web
## 4. Practical Word
Pattern: ^[a-zA-Z]+(?:['-][a-zA-Z]+)*$
Readability: MEDIUM | Performance: HIGH | Accuracy: MEDIUM
Pros:
- Better control over hyphens/apostrophes
- Prevents awkward combinations
- Still ASCII-focused
- Good structure
Cons:
- ASCII-only
- More complex
- No international support
- Restrictive format
Best For: English name validation, word games
## Recommendation
Use "Unicode Words" for international support. For English-only, "With Hyphens/Apostrophes" is usually sufficient.
## Performance Benchmark (hello)
- Simple ASCII: 7,200,000 ops/sec
- With Hyphens: 6,800,000 ops/sec
- Unicode: 4,500,000 ops/sec
- Practical: 6,200,000 ops/sec
## Common Pitfalls
1. \w includes underscore and numbers
2. Different regex engines handle Unicode differently
3. Consider locale-specific characters
4. For natural language processing, use dedicated libraries
5. Remember that "word" is culturally and linguistically variable