regex - Split line by +-*/() (as delimeters) without omitting them in python -
Good day.
I'm trying to split (tokenize) like a string
(22 + 33) * 44/300
But it omits the delimiter and creates an element in the list. ['' ('22', '+', '33', ')', '*', '44', '/', '300 So far I tried to use
infix = input ("infix notation:") infix = re.split (r '[ + - / * ()] ', infix)
Instead of dividing the string on the delimiter, I recommend searching only for token.
& gt; & Gt; & Gt; ('22', '+', '33', ')', '*', '44', 'review' '/', '300']
Comments
Post a Comment