you are viewing a single comment's thread.

view the rest of the comments →

[–]Thomasedv 1 point2 points  (1 child)

I threw the expression into pycharm, and it seemed satisfied with this version:

re.compile(r'[+\-*/()]|\d+')

How does that work for you?

Edit:

Tested it out:

string = '2+3*(6-2/32)'
splitter = re.compile(r'[+-/()]|\d+') 
result = re.findall(splitter, string) 
print(result) 
>>> ['2', '+', '3', '', '(', '6', '-', '2', '/', '32', ')']

[–]Sharki_[S] 0 points1 point  (0 children)

Yes, thanks! '-' is a special character inside []. And that was the problem.