fork download
  1. #include <iostream>
  2. #include <regex>
  3.  
  4. bool containsOnlyAllowedSymbols(char const *equation)
  5. {
  6. std::regex re(R"([^0-9(){}[\]*+-/])");
  7. return !std::regex_search(equation, re);
  8. }
  9.  
  10. int main()
  11. {
  12.  
  13. std::cout << containsOnlyAllowedSymbols("(10+20)-200*4") << std::endl;
  14. std::cout << containsOnlyAllowedSymbols("10+20-{200}abc") << std::endl;
  15.  
  16. return 0;
  17. }
Success #stdin #stdout 0s 4560KB
stdin
Standard input is empty
stdout
1
0