import re
s_old = "1 - 2 * ( (60-30 +(-40/5) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568/14 )) - (-4*3)/ (16-3*2) )"
s_new = s_old.replace(' ','')
print(s_new)
ret = re.search("([^(^)]*)",s_new)
#
# for i in ret:
# ret = re.search("-?d+[*|\]d+",i)
# while ret:
# re.sub("-d+[*|\]d+",eval(ret.group()),i,1)
#
# input("123)
ret1 = re.search("-?d+[*|/]d+", ret.group())
print(ret1.group())
s_new = re.sub('-?d+[*|/]d+',str(eval(ret1.group())),s_new,1)
print(s_new)
# while ret:
# re.sub("-d+[*|\]d+", eval(ret.group()), i, 1)
#
# input("123)