I am currently using Regex and I have absolutely no idea how to. I got somewhere with the help of msdn, but not far enough:
So below I copied and pasted Regex code that I want to include with another rule I need. This code below does not allow special characters as well as numbers in the field:
[RegularExpression(@"^[a-zA-Z''-'\s]{1,40}$", ErrorMessage =
"Numbers and special characters are not allowed in the Title.")]
I need this as well as a restriction on using capital letters after every space.
Example: Every Day I Learn Something New <--Correct
but not: Every day i learn something new. <--Incorrect
Just like making a title for an article.
If you can help out an uneducated Regex coder that would be much appreciated
Cheers
This question describes how to do negative matches. For your case, you could also require that string match @"^((?!\s[a-z]).)*$".
([A-Z]+[A-Za-z]*\s+)*
You can test your Regex on this site Regex Tester
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With