如果模式“regular”是变量 st 的子字符串,我想返回输出“match”。这可能吗?
int main()
{
string st = "some regular expressions are Regxyzr";
boost::regex ex("[Rr]egular");
if (boost::regex_match(st, ex))
{
cout << "match" << endl;
}
else
{
cout << "not match" << endl;
}
}
最佳答案
boost::regex_match 只匹配整个字符串,您可能需要 boost::regex_search。
关于c++ - boost 正则表达式子字符串匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2061885/