Newbie here trying to reimplement PHP's preg_match_all() function in C++. I'm rewriting a PHP class which functions as a Porter Stemmer. I seem to have the regex_replace code working nicely but am now stuck on regex_match/regex_search. I want to count the number of times a regex matches within a string. The regex attempts to match all occurrences of one+ vowels followed by one+ consonants (known as 'm' or measure, roughly equivalent to a syllable). The original PHP function is as follows: private static function m($str) { $c = '(?:[bcdfghjklmnpqrstvwxz]|(?<=[aeiou])y|^y)'; $v = '(?:[aeiou]|(?string::const_iterator what; match_flag_type flags = match_default | match_partial; regex_search(start, end, what, expression, flags); string thing = what[1]; int size = thing.size(); cout << what[1] << endl; string s; stringstream out; out << size; s = out.str(); return s; } This does not replicate the last two lines of PHP code above, instead returning the number of characters in a substring of sorts. So yes, I'm lost! Have tried several variations/possibilities but can't find a good example to work with. Have tried some much simpler variations they're not working either. TIA for any tips, even on which regex function I should be using. Mick