, :
pat = r"^([NS])(\d+)°(\d+)'([\d.]*)\"?([EW])$"
:
import re
r = re.compile(pat)
m = r.match(thestring)
if m is None:
print "%r does not match!" % thestring
else:
print "%r matches: %s" % (thestring, m.groups())
, m.groups() thestring, , , pat - N S, .. , "" .