If I input "110110" in to the application, the first chunk prints out "1" while the second chunk prints out "2".
Why are the results different?
How can I construct the regex pattern in the function call?
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
auto begin = sregex_iterator(s.begin(),s.end(),regex{R"(110)"});
auto end = sregex_iterator();
cout << distance(begin,end) << endl;
const regex r(R"(110)");
begin = sregex_iterator(s.begin(),s.end(),r);
end = sregex_iterator();
cout << distance(begin,end) << endl;
}