I have a simple query. I am new to regular expression validations in C#.
I want some expression which would allow only single alphabet that means a-z or A-Z. It should not allow whole word. Can anyone suggest me an expression?
The following should work:
[a-zA-Z]+
This expression allows one or more characters in the specified range. And if you want only a single character:
[a-zA-Z]
gr[ae]y will not match graay, graey or any such thing. Use a hyphen to specify a range: [0-9] matches a single digit between 0 and 9. You can use more than one range: [a-zA-Z] matches a single letter, case insensitively. You can combine ranges and single characters. [a-z,A-Z] matches a lowercase or uppercase letter or the comma. The order of characters and ranges does not matter.