I have a long string (8000 characters) that should contain only hexadecimal and newline characters.
What is the best way to validate / verify that the string does not contain invalid characters?
Valid characters are: 0 through 9 and A through F. Newlines should be acceptable.
I began with this code, but it does not work properly (i.e. fails to return false when a "G" is the first character):
public static bool VerifyHex(string _hex)
{
Regex r = new Regex(@"^[0-9A-F]+$", RegexOptions.Multiline);
return r.Match(_hex).Success;
}