This should be a fairly simple question, but I seem to be overthinking it.
I have an input that I need to make sure does not have any characters that are not ASCII printable characters (character code 32-127).
string someString = "6244ABº¿º";
var regexPattern = new Regex("^$|[ -~]*");
if (regexPattern.IsMatch(someString))
{
//invalid format
}
Here's an idea of what I want as inputs and outputs:
Input: AB2RAF@#%$@% Ouput: Valid (All are within ASCII 32-127)
Input: º¿º234234 Ouput: Invalid (Has 'º' and '¿')
Input: AAABCC Ouput: Valid
Edit: I think it's the regex that's backwards. It has something to do with the '*'?