using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"([+-]? ?[0-9]{1,3}(deg|°|\*)) ?([0-9]{1,2}\.?[0-9]*?(min|'|’| ))? ?([0-9]{1,2}\.?[0-9]*?(sec|""|”| ))?( ?[NSEW]?)";
string input = @"This is the start of a validator for Degrees Minutes Seconds for GeoMapping
38° 24' 55"" -78deg 28' 52"" W
12345 North south aasdf#asdf
125415 S asdf/asdf/asdf
asdf""ASDF""asdf'
!@#$%^&*()_+.[]__ ASDF __ASDF__
38° 24' -78deg 28' 52"" W
38° 24' 55"", -78deg 28' 52"" W
-39.1234567 77.123456
77.123456
38.0818651958795, -78.4788168125323
38 -78
38N -78
38 N -78
38 N, -78
";
RegexOptions options = 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