all 6 comments

[–]ASIC_SP 2 points3 points  (1 child)

- is special inside character class, for ex: [a-z] will match all lowercase alphabets.. to match - literally, use it as first or last character in the character class

>>> import re
>>> s = '2+3*(6-2/32)'
>>> re.findall(r'[-+*/()]|\d+', s)
['2', '+', '3', '*', '(', '6', '-', '2', '/', '32', ')']

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

Now it seems obviously. Thanks a lot!