^09(1\d|3[1-9])-\d{3}-\d{4}$
is the regular expression that you need:
Starting with the beginning of the string (so no other digits sneak in)
09 is constant
1 can be combined with any subsequent digit, 3 cannot be combined with 0
-, and 3 digits
-, and 4 digits
End of string (again, so no other digits sneak in)
... but don't take my word for it, run it (I would recommend adding more test numbers):
List<string> possible = new List<string> { "091-555-8888",
"0915-888-4444",
"0930-885-8844",
"0955-888-8842" };
string regex = @"09(1\d|3[1-9])-\d{3}-\d{4}$";
foreach (string number in possible)
{
Console.WriteLine("{0} is{1} an Iranian number", number, Regex.IsMatch(number, regex) ? "" : " not");
}
answered 2011-10-27T08:46:57.863