fork(1) download
  1. #include <iostream>
  2. #include <regex>
  3. using namespace std;
  4.  
  5. int main() {
  6. std::regex regx("\\$(\\w+)\\$(\\d+)");
  7. std::string inString("$C$5:$F$89");
  8. std::vector<std::string> vecCol;
  9. std::vector<std::string> vecRow;
  10.  
  11. for(std::sregex_iterator i = std::sregex_iterator(inString.begin(), inString.end(), regx);
  12. i != std::sregex_iterator();
  13. ++i)
  14. {
  15. std::smatch match = *i;
  16. std::cout << "Whole match: " << match.str() << ", Group 1: " << match.str(1) << ", and Group 2: " << match.str(2) << '\n';
  17. //add them to the vecs
  18. vecCol.push_back(match.str(1));
  19. vecRow.push_back(match.str(2));
  20. }
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 4196KB
stdin
Standard input is empty
stdout
Whole match: $C$5, Group 1: C, and Group 2: 5
Whole match: $F$89, Group 1: F, and Group 2: 89