Created
February 13, 2017 14:33
-
-
Save MagicHen25/1210fadecf34adff1bdb6b78a3231743 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
1 - 2 * ( (60-30 +(-40/5) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568/14 )) - (-4*3)/ (16-3*2) ) | |
''' | |
import re | |
calcStr = "1 - 2 * ( (60-30 +(-40/5) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568/14 )) - (-4*3)/ (16-3*2) )" | |
calcStr = re.sub("\ ","",calcStr) | |
# print(calcStr) | |
tmpStr = "" | |
# tmpStr = re.search("\([\(\)\+\-\*/\d]+",calcStr) | |
# print(tmpStr.group()) | |
def strExecute(inStr): | |
print(inStr) | |
outStr = "" | |
outStr = re.search("\([\(\)\+\-\*/\d]+",inStr) | |
if outStr is not None: | |
outStr = strExecute(outStr.group(0)[1:]) | |
print("pos1",outStr) | |
return outStr | |
else: | |
return inStr | |
tmpStr = strExecute(calcStr) | |
print("[Final]:",tmpStr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment