I want to create a scraper , to studying. I try to get all exactly 10 digit long numbers possible in a file.
#include <fstream>
#include <iostream>
#include <regex>
int main()
{
std::string subject("098765432123 1234567890");
try {
std::regex re("[0-9]{10}");
std::sregex_iterator next(subject.begin(), subject.end(), re);
std::sregex_iterator end;
while (next != end) {
std::smatch match = *next;
std::cout << match.str() << "\n";
next++;
}
} catch (std::regex_error& e) {
// Syntax error in the regular expression
}
}
My output is :
0987654321
1234567890
But with this string "098765432123 1234567890" I want to obtain all numbers like :
0987654321
9876543212
8765432123
1234567890
I don't know if the problem come from my regex or from next++
Thanks for your advise.