On 2006-09-05,
gi*******************@yahoo.com <gi*******************@yahoo.comwrote:
What is the regular expression that checks that every character in a
string is in [0-9][A-F] ?
mystring="abcd1023"
reg=/^[0-9A-F]*$/i
print(reg.test(mystring))
^: Start
$: End
[0-9A-F]: Hex characters, but only capitals
"/i": ignore case (to get lower case characters as well)
(one could use [0-9A-Fa-f] to check upper and lower explicitly)
print(.): I am using the Firefox spider monkey (Javascript 1.5[*])
interpreter (which uses print(.) to output results).
One a web page, use alert(.) instead of print(.).
*: There is a 1.6 version out, but the interpreter is not
standalone but requires the installation of the libraries.
I have not installed that one yet.
/^[0-9A-Fa-f]*$/i
Beginning of line, then an string of any number (even zero)
hex characters (ignore case) and then end of line (so ONLY
hex characters - i.e. a line made up only of hex chars).