I’m writing validation regex in c# – basically need to ensure that property does not have “:” in it. I’m total newbee with regex. This is what I have and it doesn’t seem to work.. I read beginners FAQ on regex and this is what I came up with "[^:]"
[StringLengthVerifier(MaxValue = 25, IsRequired = true, ErrorMessageResourceName = "MEMUser_UserName")]
[RegexVerifier("User Name", @"[^:]", ErrorMessage = "User name cannot contain colons")]
public string UserName { get; set; }
By enclosing the character class with the string/line boundary meta characters:
and using the right regex mode for making them match the beginning/end of string.
Or by using
(assuming C# regex support them).