Visual Studio 2013兼容性中的C++Regex

C++ Regex from Visual Studio 2013 compatibility

本文关键字:C++Regex 兼容性 Studio 2013 Visual      更新时间:2023-10-16

这是我在一次漫长的旅程中的后续操作,我在C++11中使用正则表达式和VS 2013 rc5从解析GLSL着色器文件中提取文本。

以下是监督结果:

实时工作编辑在这里!

C++等价物看起来像这样,它是PHP版本的翻版:

std::smatch u;
std::string s = l_shader->GetData();
std::smatch u;
std::regex_search(s.cbegin(), s.cend(), u, std::regex("<(\S+)[!]>([.*\s*\S*]*?)<[!]\S+>"));

不幸的是,std::regex_search没有返回任何结果。我一直想弄清楚。我错过了什么?

对我来说,这看起来像是一个bug。我可以确认,使用VC++2013,没有任何东西匹配——但使用VC++2015,每个着色器都匹配,正如(我认为)你所期望的那样。