In C#, what is the Regex to check for alphanumeric characters? Everytime I try the expression below, it returns false!
^[a-zA-Z0-9]$
removing the ^ and $ doesnt work entirely either.
Printable View
In C#, what is the Regex to check for alphanumeric characters? Everytime I try the expression below, it returns false!
^[a-zA-Z0-9]$
removing the ^ and $ doesnt work entirely either.
What is the text you are searching?
Don't forget to put a pipe-delimiter between them in the square brackets. Example, "^[a-z|A-Z|0-9]$".
Not in a character class.Quote:
Originally Posted by tacoman667
Thanks.
Well I got it to work to use 2 different patterns:
[a-zA-Z]
[0-9]
the text would be anything entered at all, such as a password. Want to check to see that it DOES contain at least 1 letter and number in the string given to this method. I would rather have it done in 1 go rather than calling it twice with seperate REGEX pattern
+ means "at least one"Code:^[a-zA-Z0-9]+$
alternatively
Code:string myregex = @"^(\d|\w)+$";