当前位置: 动力学知识库 > 问答 > 编程问答 >

c++ - GCC has problems with \d in std::regex

问题描述:

I have the following regular expression object that I create:

std::regex magStripe{R"(^%B(\d+)\^)"};

(Full, working sample here)

When this regex object is constructed, std::regex_error is thrown with code set to 2, which happens to be std::regex_constants::error_escape. I did some process of elimination and when I remove the \d, it works just fine.

I tested this on VS 2013 and it does not throw an exception. I tested this on Coliru and it seems to completely crash. If I use clang++ it works.

Why isn't this regex working on GCC? Am I doing something wrong?

分享给朋友:
您可能感兴趣的文章:
随机阅读: