std::regex bug in vs2010 - by prog76

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 641845 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 2/7/2011 9:45:52 PM
Access Restriction Public


When matching with std::regex results is wrong. Group 4 should not be empty.

 123T 'DATA'(THE)
Sign in to post a comment.
Posted by Microsoft on 2/8/2011 at 6:52 PM

Thanks for reporting this bug. We've already fixed it, and the fix will be available in VC11. Here's a slightly modified test case with the same string and regex:

C:\Temp>type meow.cpp
#include <stddef.h>
#include <iostream>
#include <ostream>
#include <regex>
#include <string>
using namespace std;

int main() {
    cout << "_MSC_FULL_VER: " << _MSC_FULL_VER << endl;

    const string s(" 123T 'Data'(THE)");
    const string reg("^\\s*(\\d\\d\\d)T\\s+'(.*)'\\s*(?:\\((\\d+)\\))?\\s*(?:\\(\\s*(.*?)\\s*\\))?.*");
    const regex r(reg);

    cout << " s: \"" << s << "\"" << endl;
    cout << " r: \"" << reg << "\"" << endl;

    smatch m;

    if (regex_search(s, m, r)) {
        for (size_t i = 0; i < m.size(); ++i) {
            cout << "m[" << i << "]: \"" << m[i] << "\"" << endl;
    } else {
        cout << "FALSE" << endl;

[VC10 RTM]
C:\Temp>cl /EHsc /nologo /W4 meow.cpp

_MSC_FULL_VER: 160030319
s: " 123T 'Data'(THE)"
r: "^\s*(\d\d\d)T\s+'(.*)'\s*(?:\((\d+)\))?\s*(?:\(\s*(.*?)\s*\))?.*"
m[0]: " 123T 'Data'(THE)"
m[1]: "123"
m[2]: "Data"
m[3]: ""
m[4]: ""

[My current build of VC11]
C:\Temp>cl /EHsc /nologo /W4 meow.cpp

_MSC_FULL_VER: 170040203
s: " 123T 'Data'(THE)"
r: "^\s*(\d\d\d)T\s+'(.*)'\s*(?:\((\d+)\))?\s*(?:\(\s*(.*?)\s*\))?.*"
m[0]: " 123T 'Data'(THE)"
m[1]: "123"
m[2]: "Data"
m[3]: ""
m[4]: "THE"

If you have any further questions, feel free to E-mail me at .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by Microsoft on 2/7/2011 at 9:58 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(