mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-07 02:02:18 +00:00
14 lines
255 B
Go
14 lines
255 B
Go
|
package bytesutil
|
||
|
|
||
|
import "regexp"
|
||
|
|
||
|
var hexRegex = regexp.MustCompile("^0x[0-9a-fA-F]+$")
|
||
|
|
||
|
// IsHex checks whether the byte array is a hex number prefixed with '0x'.
|
||
|
func IsHex(b []byte) bool {
|
||
|
if b == nil {
|
||
|
return false
|
||
|
}
|
||
|
return hexRegex.Match(b)
|
||
|
}
|