In the system I am working on, regular expressions are used to enforce some specific input format for WPF Textboxes.
A behavior gets assigned a Regex object and controls the chars being typed and only let the ones valid go through. (solution similar to this article )
There is one exception however. When only upper case chars will be accepted, the chars being typed should be automatically converted to upper case instead of being rejected.
My question is:
How to elegantly determine that the regular expression, supplied in a Regex object, will only accept upper case? Is the only option to test a lower case string and then a upper case string against it? example:
if (Regex.IsMatch("THIS SHOULD PASS") && !Regex.IsMatch("this should fail")
{
// logic to convert lower case to upper case.
}