1

如果我的正则表达式模式具有以下形式,则 regex_search 在匹配字符串中的某些内容时是否等同于 regex_match:,^.......$即如果我告诉匹配的内容应该在字符串的开头并且应该以字符串的结尾结尾?还是有其他区别?

4

1 回答 1

4

不,它们不等价,因为 regex_search 中的 $ 将匹配 line-end 而 ^ 将匹配 line-start。因此,在多行字符串中,regex_search 仍会找到子匹配项。我猜想添加标志 boost::match_not_eol 和 boost::match_not_bol 会创建 regex_match 行为。

于 2013-01-10T10:56:16.513 回答