20198 is valid Hex though, just because it doesn't contain any letters doesn't mean it's not Hex. The code above just tests whether a string contains only numbers and letters A through F.