C ++ Regex从Visual Studio 2013兼容性 [英] C++ Regex from Visual Studio 2013 compatibility

查看:382
本文介绍了C ++ Regex从Visual Studio 2013兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个漫长的旅程的后续行程,我已经拉出我的头发从解析GLSL着色器文件使用正则表达式在C + + 11与VS 2013 rc5。



以下是附带结果:





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,每个着色器都与你期望的匹配。


This is a follow-up on a long journey where I've pulled my hair out extracting text from parsing GLSL shader files using regex in C++11 with VS 2013 rc5.

Here is the intendant result:

Real time work editor here!

The C++ equivalent looks like this, which is a copycat of the PHP version:

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+>"));

Unfortunately, std::regex_search doesn't return any results. I've been banging my head trying to figure it out. What am I missing?

解决方案

It looks like a bug to me. I can confirm that with VC++2013, nothing matches--but with VC++ 2015, each shader matches, as (I think) you expect.

这篇关于C ++ Regex从Visual Studio 2013兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆