Namespaces
Variants

std::regex_iterator<BidirIt,CharT,Traits>:: operator*,operator->

From cppreference.net
Regular expressions library
Classes
(C++11)
Algorithms
Iterators
Exceptions
Traits
Constants
(C++11)
Regex Grammar
const value_type & operator * ( ) const ;
(1) (自 C++11 起)
const value_type * operator - > ( ) const ;
(2) (自 C++11 起)

regex_iterator 中提取当前的 std::match_results

返回值

1) 返回对当前 std::match_results 的引用。
2) 返回指向当前 std::match_results 的指针。

示例

#include <iostream>
#include <regex>
#include <string>
int main()
{
    std::string hay{"1.1a2b3cjk34"};
    std::regex needle("[1234]");
    using Ri = std::regex_iterator<std::string::iterator>;
    for (Ri it{hay.begin(), hay.end(), needle}, last{}; it != last; ++it)
        std::cout << it->str();
    std::cout << '\n';
}

输出:

112334