using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(\+?(?:(84|0))(\s?[\-\u2010\u2011\u2012\u2013\u2014\u2015]?\s?)[357-9]\d{6}(?:\d{2}(?:\d{1})?)?)";
string input = @"1234567
76543211234
123456789
12345778
1234567890
+8412345678
84123456789
8412345
84123456
+1234567
+84
0123456
+84356763987
5123456
31234567
712345678
9123456789
+84-5123456
+84 5123456
05123456
0-5123456
+84 - 5123456
843378262
84337671542
84575516147
";
RegexOptions options = RegexOptions.Multiline;
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