Python:
import re
from math import sqrt
class Point:
def __init__(self, x_init, y_init):
self.x = x_init
self.y = y_init
def shift(self, x, y):
self.x += x
self.y += y
def __repr__(self):
return "".join(["Point(", str(self.x), ",", str(self.y), ")"])
def distance(a, b):
return sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2)
def pointRegex(str2Check: str) -> Point:
# extracts int coordinates out of a string (used for mapping the chobits environment)
theRegex: str = "[-+]?[0-9]{1,13}"
result: Point = Point(0, 0)
m = re.search(theRegex, str2Check)
result.x = int(m.group(0))
phase2: str = str2Check.replace(f"{result.x}", "")
m = re.search('[-+]?[0-9]{1,13}(\\.[0-9]*)?', phase2)
phase2 = int(m.group(0))
result.y = int(phase2)
return result
print(pointRegex('3,5'))