I am trying to detect if a string is a Hex Code (please let me know if there is any better way to do it), but to begin with I started to check if the string I'm looking at is a number 0-9 of length 2:
def is_hex(text):
if re.match('^[0-9]{0,2}',text):
print("The text \n" + text + "\n has been identified as HEX code")
print(re.search('^[0-9]{0,2}',text))
else:
print("The text \n" + text + "\n has >NOT< been identified as HEX code")
Then I run some tests, but ANY string will go through, just like this one "Proba de Merda":
The text Proba de Merda has been identified as HEX code Evaluate next item
Am I missing something?
Thanks