Blockhashes are always 64 characters in length.
/^[0-9a-f]{64}$/i
سؤال
I'm trying to identify if a URL component includes a bitcoin block hash
, which looks like 000000000d32098b5faf86d17cb6e1828ac98f3b104f019dd78bfc9fdc1ae7b0
What's a regex I can use to identify that this is a block hash as opposed to a regular number or string?
المحلول
Blockhashes are always 64 characters in length.
/^[0-9a-f]{64}$/i
نصائح أخرى
If you want to match the strings which are having at least a digit(0-9) and at least a character(a-f), and overall length of the string is 10 characters. Then you can use this one:
^(?=.*\d)(?=.*[a-fA-F])[a-fA-F\d]{10}$