다음을 통해 공유


regex_search Function

정규식 일치를 검색 합니다.

template<class BidIt, class Alloc, class Elem, class RXtraits, class Alloc2>
    bool regex_search(BidIt first, Bidit last,
        match_results<BidIt, Alloc>& match,
        const basic_regex<Elem, RXtraits, Alloc2>& re,
        match_flag_type flags = match_default);
template<class BidIt, class Elem, class RXtraits, class Alloc2>
    bool regex_search(BidIt first, Bidit last,
        const basic_regex<Elem, RXtraits, Alloc2>& re,
        match_flag_type flags = match_default);
template<class Elem, class Alloc, class RXtraits, class Alloc2>
    bool regex_search(const Elem* ptr,
        match_results<const Elem*, Alloc>& match,
        const basic_regex<Elem, RXtraits, Alloc2>& re,
        match_flag_type flags = match_default);
template<class Elem, class RXtraits, class Alloc2>
    bool regex_search(const Elem* ptr,
        const basic_regex<Elem, RXtraits, Alloc2>& re,
        match_flag_type flags = match_default);
template<class IOtraits, class IOalloc, class Alloc, class Elem, class RXtraits, class Alloc2>
    bool regex_search(const basic_string<Elem, IOtraits, IOalloc>& str,
        match_results<typename basic_string<Elem, IOtraits, IOalloc>::const_iterator, Alloc>& match,
        const basic_regex<Elem, RXtraits, Alloc2>& re,
        match_flag_type flags = match_default);
template<class IOtraits, class IOalloc, class Elem, class RXtraits, class Alloc2>
    bool regex_search(const basic_string<Elem, IOtraits, IOalloc>& str,
        const basic_regex<Elem, RXtraits, Alloc2>& re,
        match_flag_type flags = match_default);

매개 변수

  • BidIt
    부분에 대 한 반복기의 형식입니다.

  • Alloc
    일치 결과 할당자 클래스입니다.

  • Elem
    일치 하는 요소의 형식입니다.

  • RXtraits
    특성 클래스 요소입니다.

  • Alloc2
    정규식 할당자 클래스입니다.

  • IOtraits
    문자열 특성 클래스입니다.

  • IOalloc
    문자열 할당자 클래스입니다.

  • flags
    일치 하는 항목에 대 한 플래그입니다.

  • first
    일치 하는 시퀀스의 시작 부분입니다.

  • last
    일치 하는 시퀀스의 끝입니다.

  • match
    결과 일치 합니다.

  • ptr
    일치 하는 시퀀스의 시작 부분에 대 한 포인터입니다.

  • re
    일치 하는 정규식입니다.

  • str
    일치 하는 문자열입니다.

설명

각 템플릿 함수 검색만 하면 정규식 인수에 대해 true를 반환 re 피연산자의 순서를 성공 합니다.함수는 match_results 개체 검색의 성공 여부와 어떤 다양 한 그룹에 정규식 캡처 캡처를 반영 하도록 해당 멤버를 설정 합니다.

예제

 

// std_tr1__regex__regex_search.cpp 
// compile with: /EHsc 
#include <regex> 
#include <iostream> 
 
int main() 
    { 
    const char *first = "abcd"; 
    const char *last = first + strlen(first); 
    std::cmatch mr; 
    std::regex rx("abc"); 
    std::regex_constants::match_flag_type fl = 
        std::regex_constants::match_default; 
 
    std::cout << "search(f, f+1, \"abc\") == " << std::boolalpha 
        << regex_search(first, first + 1, rx, fl) << std::endl; 
 
    std::cout << "search(f, l, \"abc\") == " << std::boolalpha 
        << regex_search(first, last, mr, rx) << std::endl; 
    std::cout << "  matched: \"" << mr.str() << "\"" << std::endl; 
 
    std::cout << "search(\"a\", \"abc\") == " << std::boolalpha 
        << regex_search("a", rx) << std::endl; 
 
    std::cout << "search(\"xabcd\", \"abc\") == " << std::boolalpha 
        << regex_search("xabcd", mr, rx) << std::endl; 
    std::cout << "  matched: \"" << mr.str() << "\"" << std::endl; 
 
    std::cout << "search(string, \"abc\") == " << std::boolalpha 
        << regex_search(std::string("a"), rx) << std::endl; 
 
    std::string str("abcabc"); 
    std::match_results<std::string::const_iterator> mr2; 
    std::cout << "search(string, \"abc\") == " << std::boolalpha 
        << regex_search(str, mr2, rx) << std::endl; 
    std::cout << "  matched: \"" << mr2.str() << "\"" << std::endl; 
 
    return (0); 
    } 
 
  

요구 사항

헤더: <regex>

네임 스페이스: std

참고 항목

참조

<regex>

regex_match Function

regex_replace Function