Identifiersflags: g
MongoDB ObjectId
Match MongoDB ObjectId values — 24-character hexadecimal strings.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
\b[0-9a-fA-F]{24}\b (flags: g)Raw source: \b[0-9a-fA-F]{24}\b
How it works
Word-bounded exactly 24 hex digits. Case-insensitive character class covers both upper and lower case forms produced by different drivers.
Examples
Input
507f1f77bcf86cd799439011Matches
507f1f77bcf86cd799439011
Input
id: 5f8d0d55b54764421b7156c4Matches
5f8d0d55b54764421b7156c4
Input
not an objectidNo match
—Common use cases
- •API log parsing for Mongo-backed services
- •Database migration scripts
- •Query parameter validation
- •Cross-service correlation tracing
Related patterns
Semantic Version (SemVer)
IdentifiersMatch semantic version strings like 1.2.3, 1.2.3-beta.1, or 1.2.3+build.42.
ULID
IdentifiersMatch 26-character ULIDs (Universally Unique Lexicographically Sortable Identifiers).
AWS ARN (Amazon Resource Name)
IdentifiersMatch AWS ARNs (Amazon Resource Names) across commercial, China, and GovCloud partitions.
AWS S3 Bucket Name
IdentifiersValidate AWS S3 bucket names per the standard naming rules: 3–63 chars, lowercase, alphanumeric + dots + hyphens.