sub_match Class

描述一个子匹配项。

template<class BidIt>
    class sub_match
        : public std::pair<BidIt, BidIt> {
public:
    bool matched;
    int compare(const sub_match& right) const;
    int compare(const basic_string<value_type>& right) const;
    int compare(const value_type *right) const;
    difference_type length() const;
    operator basic_string<value_type>() const;
    basic_string<value_type> str() const;
    typedef typename iterator_traits<BidIt>::value_type value_type;
    typedef typename iterator_traits<BidIt>::difference_type difference_type;
    typedef BidIt iterator;
    };

参数

  • BidIt
    子匹配项的迭代器类型。

备注

模板类描述指定字符序列对名为的捕获组设置 regex_match Function 或为 regex_search Function的对象。类型 match_results Class 对象来存放一这些对象,一个用于搜索的正则表达式的每个捕获组。

如果捕获组没有对对象的数据成员 matched 保存错误,因此,两个迭代器 first 和 second (继承自基 std::pair) 相等。如果捕获组匹配, matched 应用,迭代器 first 指向在对捕获组的目标序列中的第一个字符,,以及迭代 second 点通过最后一个字符的位置在对捕获组的目标顺序。为成员 matched 应用的零长度与请注意,两个迭代器相等的,因此,和都指向匹配项的位置。

零长度匹配时,会发生捕获组仅包含断言时,允许零重复或重复。例如:

“^”与目标顺序 “a”;两个指向该序列中的第一个字符与捕获组 0 对应的 sub_match 对象来存放迭代器。

“b (a*) b”与目标顺序 “bb”;两个指向该序列中的第二个字符与捕获组 1 对应的 sub_match 对象来存放迭代器。

要求

**标题:**regex

命名空间: std

请参见

参考

<regex>

sub_match Class

regex_match Function

regex_search Function

其他资源

regex 成员