I have a regex which is to remove extra vml tags from a html page.
std::string regstr = R"(<!\[if !vml\]>([\s\S]*?)<!\[endif\]>)";
std::regex regex(regstr, std::regex_constants::ECMAScript);
std::smatch mr;
std::string str = R"(</v:shape><![endif]--><![if !vml]>
<img width=234 height=383 src="http://file/C:\Users\jcyangzh\AppData\Local\Temp\msohtmlclip1\01\clip_image002.png" v:shapes="110x110">
<![endif]></span></span><span lang=EN-US><o:p></o:p></span></p>)";
if (std::regex_search(str, mr, regex)) {
std::cout << "match found: " << mr.size() << "\n";
for (size_t i = 0; i < mr.size(); ++i) {
std::string strrep = mr.str(i);
std::cout << "index: " << i << "\n string: " << strrep << "\n\n";
}
}
For GNU GCC Compiler 4.9.2
(latest tdm-gcc windows port), the above code works. The regex I used does match.
But for visual studio 2013 update 4 the regex does not work, std::regex_search
return false.
If I replace the key pattern [\s\S]
with (\s|\S)
, there will be 3 matches.
My problem: Is [\s\S]
a valid c++11 ecma regex, or is this a bug of VS2013 update4?
Aucun commentaire:
Enregistrer un commentaire