$re = '/([+-]? ?[0-9]{1,3}(deg|°|\*)) ?([0-9]{1,2}\.?[0-9]*?(min|\'|’| ))? ?([0-9]{1,2}\.?[0-9]*?(sec|"|”| ))?( ?[NSEW]?)/i';
$str = '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
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
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 PHP, please visit: http://php.net/manual/en/ref.pcre.php