Regular expression prevents entering two-dimensional strokes and spaces in a text field in WPF

I got a regular expression that prevents the user from using two consecutive dashes. They can inject almost any other sample. The only other criteria that I am trying to implement is to prevent the user from entering any empty space anywhere in the text field. Here is my expression that works to prevent double dashes:

[RegularExpression(@"^(?:(?!--).)*$", ErrorMessage = "No double dashes please")]

Can someone help me add to this expression the ability to prevent the user from entering a space anywhere in the text field

thanks

+4
source share
1 answer

, \s :

@"^(?:(?!--|\s).)*$"
+4

All Articles