Git Commit Hash Regex
Matches full (40-char) or short (7-char) Git commit hashes.
パターン
/\b[0-9a-f]{7,40}\b/g
→ ビジュアライザーで開くテスト例
Commit a1b2c3d fixed bug. Full hash: a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0
コード例
javascript
const regex = /\b[0-9a-f]{7,40}\b/g;
const result = str.match(regex);python
import re
pattern = re.compile(r'\b[0-9a-f]{7,40}\b')
result = pattern.findall(text)go
import "regexp"
re := regexp.MustCompile(`\b[0-9a-f]{7,40}\b`)
result := re.FindAllString(text, -1)githashdevelopment