
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

Carsten Witzel wrote:
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.
I'm not sure what you mean here: do you mean that code which works with Boost.Regex fails with another/commercial implementation of the TR1 regex library? If so you'll have to contact the vendor I'm afraid, or else use Boost.Regex instead ;-) HTH, John.

I'm not sure what you mean here: do you mean that code which works with Boost.Regex fails with another/commercial implementation of the TR1 regex library? If so you'll have to contact the vendor I'm afraid, or else use Boost.Regex instead ;-)
HTH, John.
Hi, no, that's not what I wanted to say. I'm using the Boost.Regex library inside another application which has a C/C++ API. Regards, Carsten

That's still not nearly enough information. How are you using regex and how are you using it to interact with this 3rd party lib?
Sent from my Verizon Wireless BlackBerry
-----Original Message-----
From: "Carsten Witzel"

2008/11/19
That's still not nearly enough information. How are you using regex and how are you using it to interact with this 3rd party lib?
OK. Step by step:
1) It's a software application which has a C/C++ API.
2) You can write small programs with this API which are then called from
inside the software application. 3) In the source code, all I've done is
"#include

Mike Marchywka 586 Saint James Walk Marietta GA 30067-7165 415-264-8477 (w)<- use this 404-788-1216 (C)<- leave message 989-348-4796 (P)<- emergency only marchywka@hotmail.com Note: If I am asking for free stuff, I normally use for hobby/non-profit information but may use in investment forums, public and private. Please indicate any concerns if applicable. Note: hotmail is getting cumbersom, try also marchywka@yahoo.com Date: Wed, 19 Nov 2008 19:27:32 +0100 From: carsten.witzel@googlemail.com To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Regex] subexpressions 2008/11/19 That's still not nearly enough information. How are you using regex and how are you using it to interact with this 3rd party lib? OK. Step by step: 1) It's a software application which has a C/C++ API. 2) You can write small programs with this API which are then called from inside the software application. 3) In the source code, all I've done is "#include " and insert the code listed in my first posting. To repeat it again: I am not using another implementation of the Regex library. I'm using the Boost.Regex library itself from within the 3rd party software application. My question is: How can it be that this "almost" works? The example with the win32 console application works as expected. Regards, Carsten _________________________________________________________________ Windows Live Hotmail now works up to 70% faster. http://windowslive.com/Explore/Hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_faster_...

Hi, ok, I'll try to rephrase (and please correct me if I am wrong): a) You have a third party application which is closed source and you cannot debug it. b) This application can be extended by software you create yourself c) You wrote such an extension and this extension behaves weird when using boost::regex d) Your extension is a DLL and not a stand-alone program Correct? If yes, my first guess is: You are using dynamic linking and the 3rd party software has its own version of boost::regex linked into it. If this version is different to the one you are using at compile time, weird things are to be expected. Thus, my first suggestion is to use static linking for your plugin. Regards, Roland Carsten Witzel wrote:
2008/11/19
mailto:raindog@macrohmasheen.com> That's still not nearly enough information. How are you using regex and how are you using it to interact with this 3rd party lib?
OK. Step by step: 1) It's a software application which has a C/C++ API. 2) You can write small programs with this API which are then called from inside the software application. 3) In the source code, all I've done is "#include
" and insert the code listed in my first posting. To repeat it again: I am not using another implementation of the Regex library. I'm using the Boost.Regex library itself from within the 3rd party software application.
My question is: How can it be that this "almost" works? The example with the win32 console application works as expected.
Regards, Carsten
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

2008/11/19 Roland Bock
Hi,
ok, I'll try to rephrase (and please correct me if I am wrong):
a) You have a third party application which is closed source and you cannot debug it. b) This application can be extended by software you create yourself c) You wrote such an extension and this extension behaves weird when using boost::regex d) Your extension is a DLL and not a stand-alone program
Correct?
If yes, my first guess is:
You are using dynamic linking and the 3rd party software has its own version of boost::regex linked into it. If this version is different to the one you are using at compile time, weird things are to be expected.
Thus, my first suggestion is to use static linking for your plugin.
Regards, Roland
Hi, thanks for the hint! You've got everything right except d) My extension is a *.exe, but it cannot be run indepently. I'll try static linking, but I guess it will not solve the problem: I'm 100% sure that the main application does not use boost.regex (I've checked with dependancy walker). I can debug my plugin (as long as it's not calling functions of the main application library), but I need some hints where to look at when boost::regex is involved. Regards, Carsten

I'll try static linking, but I guess it will not solve the problem: I'm 100% sure that the main application does not use boost.regex (I've checked with dependancy walker).
It still might be that you have two versions of boost on your system, one being used at compile time, the other at runtime. In my experience, many obscure errors result from something like that. If it is not boost, check all other libraries you are using in your program. Next step: Use some memory checking library (hope there is something like that for windows...). Memory which is corrupted by the application can also give extraordinary results. If this still yields no findings, gradually remove all calls to the 3rd party software or replace the function calls by calls to dummy functions. Somewhere between the current state and that initial commandline exe the regex behavior will return to normal. This will give you a hint where to look closer or what/whom to ask in more detail. Try to reproduce the problem with something you can publish. If you find no way to reproduce the problem without the 3rd-party software, contact the vendor. Regards, Roland

2008/11/20 Roland Bock
I'll try static linking, but I guess it will not solve the problem: I'm
100% sure that the main application does not use boost.regex (I've checked with dependancy walker).
It still might be that you have two versions of boost on your system, one being used at compile time, the other at runtime. In my experience, many obscure errors result from something like that. If it is not boost, check all other libraries you are using in your program.
Next step: Use some memory checking library (hope there is something like that for windows...). Memory which is corrupted by the application can also give extraordinary results.
If this still yields no findings, gradually remove all calls to the 3rd party software or replace the function calls by calls to dummy functions. Somewhere between the current state and that initial commandline exe the regex behavior will return to normal. This will give you a hint where to look closer or what/whom to ask in more detail.
Try to reproduce the problem with something you can publish. If you find no way to reproduce the problem without the 3rd-party software, contact the vendor.
Thanks for the hints! I've checked with Microsofts TR1 implementation, and I get the same wrong result, so the problem is not Boost, but the 3rd party application.
From an older project, I remembered that the application's libs use _HAS_ITERATOR_DEBUGGING=0 and _SECURE_SCL=0, but that wasn't enough.
If anyone had an idea which #defines and #includes are _not_ allowed for boost::regex (or std::tr1::regex), that would be great! But you're right: as it's not a Boost-specific problem, I'll try to get help from the application's vendor. Regards, Carsten

Carsten Witzel wrote:
I've checked with Microsofts TR1 implementation, and I get the same wrong result, so the problem is not Boost, but the 3rd party application.
From an older project, I remembered that the application's libs use _HAS_ITERATOR_DEBUGGING=0 and _SECURE_SCL=0, but that wasn't enough.
If anyone had an idea which #defines and #includes are _not_ allowed for boost::regex (or std::tr1::regex), that would be great!
Anything is allowed, but... if you define something that changes the ABI of Boost.Regex or the std lib then you *must* compile Boost.Regex with the same options. _HAS_ITERATOR_DEBUGGING=0 and _SECURE_SCL=0 almost certainly come into that category.
But you're right: as it's not a Boost-specific problem, I'll try to get help from the application's vendor.
Hmm, if the msvc regex implementation produces the same result then that suggests that either: * The regular expression is somehow changed in the application. * The string being matched isn't what you think it is in the application. * There could just possibly be some issue with the locale being changed in the application - but I can't recall what the regular expression was now to know if there's anything that might be locale sensitive. HTH, John.

Glad to read that you're coming closer to a solution. But I am sorry, I cannot help you with the includes. Regards, Roland Carsten Witzel wrote:
2008/11/20 Roland Bock
mailto:rbock@eudoxos.de> I'll try static linking, but I guess it will not solve the problem: I'm 100% sure that the main application does not use boost.regex (I've checked with dependancy walker).
It still might be that you have two versions of boost on your system, one being used at compile time, the other at runtime. In my experience, many obscure errors result from something like that. If it is not boost, check all other libraries you are using in your program.
Next step: Use some memory checking library (hope there is something like that for windows...). Memory which is corrupted by the application can also give extraordinary results.
If this still yields no findings, gradually remove all calls to the 3rd party software or replace the function calls by calls to dummy functions. Somewhere between the current state and that initial commandline exe the regex behavior will return to normal. This will give you a hint where to look closer or what/whom to ask in more detail.
Try to reproduce the problem with something you can publish. If you find no way to reproduce the problem without the 3rd-party software, contact the vendor.
Thanks for the hints!
I've checked with Microsofts TR1 implementation, and I get the same wrong result, so the problem is not Boost, but the 3rd party application.
From an older project, I remembered that the application's libs use _HAS_ITERATOR_DEBUGGING=0 and _SECURE_SCL=0, but that wasn't enough.
If anyone had an idea which #defines and #includes are _not_ allowed for boost::regex (or std::tr1::regex), that would be great!
But you're right: as it's not a Boost-specific problem, I'll try to get help from the application's vendor.
Regards, Carsten
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (5)
-
Carsten Witzel
-
John Maddock
-
Mike Marchywka
-
raindog@macrohmasheen.com
-
Roland Bock