다음을 통해 공유


sub_match 클래스

Describes a submatch.

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
    The iterator type for submatches.

설명

The template class describes an object that designates a sequence of characters that matched a capture group in a call to regex_match 함수 or to regex_search 함수. Objects of type match_results 클래스 hold an array of these objects, one for each capture group in the regular expression that was used in the search.

If the capture group was not matched the object's data member matched holds false, and the two iterators first and second (inherited from the base std::pair) are equal. If the capture group was matched, matched holds true, the iterator first points to the first character in the target sequence that matched the capture group, and the iterator second points one position past the last character in the target sequence that matched the capture group. Note that for a zero-length match the member matched holds true, the two iterators will be equal, and both will point to the position of the match.

A zero-length match can occur when a capture group consists solely of an assertion, or of a repetition that allows zero repeats. 예를 들면 다음과 같습니다.

"^" matches the target sequence "a"; the sub_match object corresponding to capture group 0 holds iterators that both point to the first character in the sequence.

"b(a*)b" matches the target sequence "bb"; the sub_match object corresponding to capture group 1 holds iterators that both point to the second character in the sequence.

요구 사항

헤더:<regex>

네임스페이스: std

참고 항목

참조

<regex>

sub_match 클래스

regex_match 함수

regex_search 함수

기타 리소스

<regex> 멤버