Identifiersflags: g
Git Commit SHA
Match Git commit hashes, both short (7 chars) and full (40 chars) forms.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
\b[0-9a-f]{7,40}\b (flags: g)Raw source: \b[0-9a-f]{7,40}\b
How it works
Hexadecimal string of 7 to 40 lowercase characters, word-bounded. Covers Git's abbreviated SHAs and full SHA-1 hashes.
Examples
Input
commit 75d2cb0Matches
75d2cb0
Input
e7827cc1234567890abcdef1234567890abcdef1Matches
e7827cc1234567890abcdef1234567890abcdef1
Input
zzzzzzzNo match
—Common use cases
- •Extracting SHAs from build logs
- •CI/CD pipeline tagging
- •Changelog generation
- •Issue/PR cross-linking tooling
Related patterns
Git Remote URL (HTTPS or SSH)
IdentifiersMatch git remote URLs in both `git@host:org/repo` and `https://host/org/repo` forms.
AWS S3 Bucket Name
IdentifiersValidate AWS S3 bucket names per the standard naming rules: 3–63 chars, lowercase, alphanumeric + dots + hyphens.
Kubernetes Pod Name (RFC 1123)
IdentifiersValidate Kubernetes pod names per the RFC 1123 DNS label rules — lowercase, ≤63 chars, no leading/trailing hyphen.
AWS ARN (Amazon Resource Name)
IdentifiersMatch AWS ARNs (Amazon Resource Names) across commercial, China, and GovCloud partitions.