I have a regular expression to check the data entered in a text box. It allows only alpha numeric plus hyphen (-), underscore (_) and white spaces. It works fine for singe values. But if I enter multiple spaces or underscores, it fails. Below is my expression:
Regex.IsMatch(Text, "^[A-Za-z0-9-_ ]*$")
Please suggest if there is any other way to do this or the expression can be changed.
This expression is used in a multi-line text box, so line breaks have to be included as well.