We have regex
library in C++. By using it, I want to parse tokenize the following mathematical expression.
(bar+3)*foo/3+-1
as
(
bar
+
3
)
*
foo
/
3
+
-1
To do it, I tried that one but it gives no output contrary to expected, not tokenize
std::string s ("(bar+3)*foo/3+-1");
std::smatch m;
std::regex e ("^[-+(]*[[:digit:]]+[)]*([-+*/][-+(]*[[:digit:]]+[)]*)*$");
How can it be done?
Edit: Sorry for miswriting.