Jump to content

Recommended Posts

Posted (edited)

Checks if a string is hexadecimal.

Function and Example:

#include <MsgBoxConstants.au3>

MsgBox($MB_SYSTEMMODAL, '', '0xFFFF00: ' & _IsHex('0xFFFF00'))
MsgBox($MB_SYSTEMMODAL, '', '0XGHXX190: ' & _IsHex('0XGHXX190'))

; #FUNCTION# ====================================================================================================================
; Name ..........: _IsHex
; Description ...:  Checks if a string is a hexadecimal value.
; Syntax ........: _IsHex($sString)
; Parameters ....: $sString             - A hexadecimal string.
; Return values .: Success - True
;                  Failure - False
; Author ........: guinness
; Example .......: Yes
; ===============================================================================================================================
Func _IsHex($sString)
    Return StringRegExp($sString, '^0x[[:xdigit:]]+$') > 0 ; Or the class [0-9A-Za-z].
EndFunc   ;==>_IsHex
Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • 10 months later...
Posted

Optimised regular expression and removed ConsoleWrite() function in the _IsHex() function.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...