Tried using the following regex code but the – key cant be accepted into my input textbox. Please assist!
My code is as followed:
if (Regex.IsMatch(textBox_address.Text, @"^[a-zA-Z0-9#- ]+$"))
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Escape the
-by replacing it by\-:As you may see in this expression the
[.-.]if used to define a set of characters. To explain the regex parser, that your character has not this meaning use\to escape it.It would be the same thing if you want to a regex that matches only numbers and
[.To do it :
^[0-9\[]+$otherwise the regex can’t be parsed.