SHA-256 Hash Regular Expression

A regular expression to match SHA-256 hashes (64 hexadecimal characters).

^[A-Fa-f0-9]{64}$

If you’re looking for a regex that match a SHA-256 word within a string:

/\b([a-f0-9]{40})\b/

SHA-1 Hash Examples:

  • b581e46042cbfbb0af4542a858079a84fd3ae98e5563f615710191d5b3597680
  • 21A0270B7F66A1E4C25933F13A1E5A1BBB4757578072930C8189131F9C6AAAE1

See Also:

Regex Is Copied!