I have been looking for a good way to calculate the number of sub-strings of a particular type in a string, say, I want to count the occurrences of 'sms' in the string 'smstyuismsms'. I found an answer in a forum where somebody suggested making use of regex_iterator. But, when I tried it as follows:
string in = "smstyuismssms";
cout << distance(regex_iterator(in.begin(), in.end(), regex("sms")),regex_iterator()) << "\n";
It throws an error saying
error: missing template arguments before '(' token
So, if not this, then what is the correct way of using regex template? Please provide some examples as well.