A Regex to match a SHA1

后端 未结 6 2005
旧巷少年郎
旧巷少年郎 2020-12-02 18:37

I\'m trying to match SHA1\'s in generic text with a regular expression.

Ideally I want to avoid matching words.

It\'s safe to say that full SHA1\'s have a d

6条回答
  •  囚心锁ツ
    2020-12-02 18:58

    I use this in ruby. It allows for a short version of the sha (6 - 8 in case of clashes) and for the full sha at 40 chars long.

    \A(([0-9a-f]{40})|([0-9a-f]{6,8}))\z
    

提交回复
热议问题