function isHexadecimalString ( $str ) {
if ( preg_match("/^[a-f0-9]{1,}$/is", $str) ) {
return true;
} else {
return false;
}
}
Tag Archive for hexadecimal
preg_match for Hexadecimal Strings
Hexadecimal to Integer
function hexaToInt(s : string) : Int64;
begin
if (s <> '') and (s[1] <> '$') then
result := strToInt64('$' + s )
else
result := strToInt64(s);
end;
String to Hexadecimal
function String2Hex(const Buffer: Ansistring): string; var n: Integer; begin Result := ''; for n := 1 to Length(Buffer) do Result := LowerCase(Result + IntToHex(Ord(Buffer[n]), 2)); end;
Hexadecimal Value
/(#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}))/