using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(\+?\(61\)|\(\+?61\)|\+?61|\(0[1-9]\)|0[1-9])?( ?-?[0-9]){7,9}$";
string input = @"+(61) 455 562 400
+61-455-562-400
+61 455 562 400
+(61)-455-562-400
+(61) 455 562 400
(02) 4371 3164
(02) 4371-3164
02 80268989
03 80268989
04 80268989
05 80268989
433245898
433 245 898
433-245-898
4555-62400
123456
08 54 587 456";
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