C++11 | 正则表达式(1)介绍了C++11中的正则表达式类库,举了一个迭代器的示例,演示使用regex、sregex_iterator、smatch的用法。这次来看看regex_search的用法。
regex_search方法的原型如下:
//(1)
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 );
//(2)
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)

本文延续C++11正则表达式系列,重点解析regex_search的用法,包括其函数原型、参数说明,并通过实例展示1、3、6种使用方式。了解如何在C++11中利用正则表达式进行字符串匹配。
350

被折叠的 条评论
为什么被折叠?



