I am trying to create a .NET regular expression (for use in a ASP.NET RegularExpressionValidator control) that matches a name in the format [First Name][Space][Surname] but does not match if a specific name is entered, say Mickey Mouse
This expression works for the first part:
^[a-zA-Z]{2,}\s{1}[a-zA-Z]{3,}$
And this seems to work for the second part:
[^Mickey Mouse]
but I can’t seem to be combine these two together into one expression
What you are currently using is a negated character class. It matches a single character that doesn’t belong to the set of characters
M,i,c,k… You get the idea.If you want to ensure your string isn’t the sequence
Mickey Mouse, you need to use a negative lookahead assertion: