regex_regex_search

regex_regex_search (정규식 부분 일치 검색)

std::regex_search은 대상 시퀀스의 어딘가에 정규식과 일치하는 부분 시퀀스가 있는지 결정하는 함수예요. C++11부터 사용할 수 있어요.

출처: cppreference

본문

<regex> 헤더에 정의되어 있고, 시그니처는 다음과 같아요.

template< class BidirIt, class Alloc, class CharT, class Traits >
bool regex_search( BidirIt first, BidirIt last,
                   std::match_results<BidirIt, Alloc>& m,
                   const std::basic_regex<CharT, Traits>& e,
                   std::regex_constants::match_flag_type flags =
                       std::regex_constants::match_default );

(1) (since C++11)

template< class BidirIt, class CharT, class Traits >
bool regex_search( BidirIt first, BidirIt last,
                   const std::basic_regex<CharT, Traits>& e,
                   std::regex_constants::match_flag_type flags =
                       std::regex_constants::match_default );

(2) (since C++11)

template< class CharT, class Alloc, class Traits >
bool regex_search( const CharT* str,
                   std::match_results<const CharT*, Alloc>& m,
                   const std::basic_regex<CharT, Traits>& e,
                   std::regex_constants::match_flag_type flags =
                       std::regex_constants::match_default );

(3)

대상 시퀀스의 어딘가에 정규식과 일치하는 부분 시퀀스가 있는지 결정해요.

    1. 시퀀스 [first, last) 어딘가에 정규식 e와 일치하는 부분이 있는지 결정해요. 성공 시 첫 번째 일치 결과를 m에 담아요.
    1. 시퀀스 [first, last) 어딘가에 정규식 e와 일치하는 부분이 있는지 결정해요.
    1. null 종료 문자열 str 어딘가에 정규식 e와 일치하는 부분이 있는지 결정해요.

반환값 (Return value)

일치가 있으면 true, 그 외에는 false.

참고 (Notes)

전체 문자열이 정확히 일치해야 하는지 검사하려면 std::regex_match를 사용해요. regex_search는 부분 일치를 검색해요.

더 알아보기 (Learn more)

cppreference