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

< P> and output such as

['' ('22', '+', '33', ')', '*', '44', '/', '300 So far I tried to use

  infix = input ("infix notation:") infix = re.split (r '[ + - / * ()] ', infix)  

But it omits the delimiter and creates an element in the list.

Instead of dividing the string on the delimiter, I recommend searching only for token.

  & gt; & Gt; & Gt; ('22', '+', '33', ')', '*', '44', 'review' '/', '300']  
Html>

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -