Given searchString = "23423asdfa-''"
This regular expression should evaluate to false but it does not! Any ideas?
Regex rgx = new Regex(@"[\w-]*");
rgx.IsMatch(searchString)
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.
It’s because you haven’t constrained it to match the entire string. Hence it is allowed to consider matches on subsets of the string. A very large subset of the string matches the data hence the regex returns true.
Try the following to force it to match the entire input.