fork(11) download
  1. #include <iostream>
  2. #include <regex>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7. auto input = "+1--12*123/+1234"s;
  8. smatch sm;
  9.  
  10. if(regex_search(input, sm, regex{ "(?:^|\\b\\W)([+-]?\\d+)" })) {
  11.  
  12. do {
  13. cout << sm[1] << endl;
  14. input = sm.suffix().str();
  15. } while(regex_search(input, sm, regex{ "(?:^\\W|\\b\\W)([+-]?\\d+)" }));
  16. }
  17. }
Success #stdin #stdout 0s 3556KB
stdin
Standard input is empty
stdout
+1
-12
123
+1234