【发布时间】:2013-09-02 10:35:09
【问题描述】:
std::string string("0");
std::regex pattern("^0$",std::regex_constants::extended);
bool match(std::regex_match(string,pattern));
我相信^ 和$ 必须分别匹配 BOL 和 EOL。因此match 应该是true,但实际上是false。我错过了什么吗?
【问题讨论】:
-
哪个编译器?
std::regex未在 g++ afaik 中实现。在大多数情况下,^/$匹配字符串的开始/结束,除非使用多行标志/设置。 -
@Qtax 我相信它是在 gcc-4.8.1 中实现的。在帖子中提供了现场演示链接。
-
仅仅因为它编译并不意味着它已经完全实现和工作。