Why is it when I specify against my ASP.NET MVC view model class the following definition:
[StringLength(11)]
[RegularExpression(@"^(09)[1-3][0-9]\d{7}$")]
public string Mobile { get; set; }
this format is Mobile in Iran:
Start with: 09
A digit number between 1 and 3
7 digit between 0 and 9
But when I enter mobile number (for example 09124208640) ModelState isn't valid and get this error message :
The field Mobile must match the regular expression '^(09)[1-3][0-9]\\d{7}$'.
^(09)[1-3][0-9]\d{7}$and input09124208640it's a match.2... A digit number between 1 and 31... 7 digit between 0 and 97is a string that's10characters long. Your regex asks something different, as does theStringLength(11)constraint.