Skip to main content

detect_pattern

Function detect_pattern 

Source
pub fn detect_pattern(value: &str) -> Option<PatternType>
Expand description

Detect pattern type from a string value.

Checks patterns in order of specificity:

  1. UUID (most specific format)
  2. ObjectId (24 hex chars)
  3. JWT (three base64 segments)
  4. Email
  5. ISO Date
  6. URL
  7. IPv4
  8. IPv6
  9. Phone
  10. Credit Card
  11. Hex String (generic fallback for hex)

Returns None if no pattern matches.

§Performance

Average: ~200ns for non-matching strings Worst case: ~1us when checking all patterns