Skip to content

Commit

Permalink
🎨 Use a regex to detect if a string is an object name or a coordinate
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed Apr 18, 2024
1 parent dec02bc commit e531c91
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ipyaladin/coordinate_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@


def parse_coordinate_string(string: str) -> SkyCoord:
if string[0].isalpha():
# Use this regex instead of isalpha : "^[JGB]?[ \t0-9.+-:]+$"
regex = r"^[0-9][0-9: hmsd.+-]+$"
if not re.match(regex, string):
return SkyCoord.from_name(string)
coordinates: tuple[str, str] = _split_coordinate_string(string)
ra: Angle or None = None
Expand Down

0 comments on commit e531c91

Please sign in to comment.