> How can I check whether a string is a hexadecimal number or not? E.g. "0x123" is a hex string, but "123" and "xyz" are not. If you just want to convert the string to a number, tonumber does that because it understands the "0x" prefix.