如何在字符串中找到与 boost 正则表达式匹配的索引?
Use the position
的成员函数match_results
:
int find_match_offset(std::string const& string_to_search,
boost::regex const& expression)
{
boost::smatch results;
if(boost::regex_match(string_to_search,results,expression))
{
return results.position()
}
return -1;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)