I'm writing a c++ program that regex's to find the cells mentioned in a give excel range string
e.g.
$C$5
$CC$4
$C$5:$F$89
because of the need to either match only once (i.e only one cell is being mentioned in the string) or twice (i.e. for when two cells are mentioned in the string; its a range) I have designed my program as thus:
//get the cell being mentioned
std::regex regx("\\$(\\w+)\\$(\\d+)");
std::smatch match;
//match[0] = whole match (only useful for debug)
//match[1] = first cell col letter ; match[2] = first cell row numb
//match[3] = second cell col letter; match[4] = second cell row numb
/*vectors for putting columns and rows values extracted in the while loop into*/
std::vector<std::string> vecCol;
std::vector<std::string> vecRow;
//put all substring matches into a vector - This loop runs infinitely
while (std::regex_search(inString.begin(),inString.end(), match, regx)) {
std::cout << match[0] << "\n";
//add them to the vecs
vecCol.push_back(match[1].str());
vecRow.push_back(match[2].str());
}
the while loop causes an issue I don't quite understand; it gets trapped in an infinite loop and continues to add in the same substring match (e.g. C4) each time round infinitely. this happens even if there is only one cell mentioned in the string that is passed in
Please can anyone explain what I'm getting wrong with this C++ regex?