Boost logo

Boost Users :

Subject: [Boost-users] [Regex] subexpressions
From: Carsten Witzel (carsten.witzel_at_[hidden])
Date: 2008-11-19 06:14:49


Hi,

I'm using the Regex library for the first time with Visual Studio 2008. I've
created a simple win32 console project, which works fine.

The code is

-------------------------------------
    const char *pattern = "^(\\w*)\\s*=\\s*(\\w*).*";
    const char *text = "Key = Value; Comment";

    boost::regex re(pattern);
    boost::cmatch match;

    std::cout << pattern << std::endl;

    std::cout << text << std::endl;

    if (regex_match(text, match, re)) {
        std::cout << "--> " << match.size() << std::endl;
        for (int i = 0; i < match.size(); ++i) {
            std::cout << i << ": " << match[i] << std::endl;
        }
    }
-------------------------------------

And the output is as expected:

--------------------------------------
^(\w*)\s*=\s*(\w*).*
Key = Value; Comment
--> 3
0: Key = Value; Comment
1: Key
2: Value
--------------------------------------

However, I've tried to use the same code with the C/C++-API of a commercial
software, and here I get the following output:
--------------------------------------
^(\w*)\s*=\s*(\w*).*
Key = Value; Comment
--> 3
- 0: Key = Value; Comment
- 1: Key = Value; Comment
- 2: Value; Comment
--------------------------------------

Does anybody have an idea what's wrong here? Unfortunately, I'm not allowed
to post any header files, so I need some hints where to look for a solution
by myself.

Thanks for any help!
Regards
Carsten Witzel



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net