Skip to main content
Version: Next

Variable: isHexString

const isHexString: (hex) => boolean = isHex

Defined in: src/utils/num.ts:30

Test if string is hex-string

Parameters

hex

string

hex-string

Returns

boolean

true if the input string is a hexadecimal string, false otherwise

Example

const hexString1 = "0x2fd23d9182193775423497fc0c472e156c57c69e4089a1967fb288a2d84e914";
const result1 = isHex(hexString1);
// result1 = true

const hexString2 = "2fd23d9182193775423497fc0c472e156c57c69e4089a1967fb288a2d84e914";
const result2 = isHex(hexString2);
// result2 = false