using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(0|\+98)9[0-9]{9}$";
string input = @"09156987452
09908472853
09153610882365
09158645287
+9814756842
+980915874622
+989908472853
+981283547
9836587498
+986859554
+989158497858
+9812457868
02154091563214587
12409156032145
091596356478
+982654789652
023654d
5588
879 091586424569
+9878546
+9999999999999
+989153610883
0915603551555555555
";
RegexOptions options = RegexOptions.Multiline | RegexOptions.IgnoreCase;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx