I am using Regex in a C# program. What I really want is an expression that will check for valid data input, letters, numbers, punctuation, space, etc. But, I am having problems getting even a simple alpha-num to work.
I defined 2 strings
const string C_RegXNumbers =
@"(?//this works
const string C_RegXAlphaNumPlus = @"^[a-zA-Z]$"; //this doesn't*
Then in the code executing the Regex
I put QnA in the tag. I had to put something, but it would not let me put in C# or Regex. Something seems not right there.
if (Regex.IsMatch(strThisData, C_RegXNumbers)) …
if (Regex.IsMatch(strThisData, C_RegXAlphaNumPlus)) ...
The first one works
The much simpler fails no matter what I have tried (took out the digits)
The input string is "Open Screen". Originally, it had an exclamation point after, but I'm just trying to figure out what I'm doing wrong, so keeping it simple.
I have cut and pasted a bunch of examples, but they all fail.
And.. does anyone have a string to, basically, accept valid keyboard text. No weird printing chars, etc. I cant find one that works in my searches. Nums, AlphaNum, /?,.:;[]{} etc.
I put QnA into the Tag field. There is no dropdown and you can not put in C# Regex. Something not working properly?