I want to extract operators like: +,-,/,* , as well as (,),_ from a string
+,-,/,*
(,),_
Eg.
a-2=b (cd)=3
output:
- ,=, (, -, ), =
This does not work:
re.finditer(r'[=+/-()]*', text)
In your re you need to avoid some backslash characters. ( + , - , ( , ) have their special meanings in re ).
re
+
-
(
)
In any case, you do not need re for this:
(c for c in s if c in '+-/*()_')