compilation trouble with boost::regex

Hello everybody, I begin with C++ and need to use some regex in my program. So I try to compile this example from the boost website : http://www.boost.org/libs/regex/example/snippets/captures_example.cpp but I get this error : ~/developpement/essai_regex/boost$ g++ -o test captures_examples.cpp captures_examples.cpp: In function «void print_captures(const std::string&, const std::string&)": captures_examples.cpp:43: erreur: «class boost::smatch" has no member named «captures" captures_examples.cpp:49: erreur: «class boost::smatch" has no member named «captures" I have already installed this library : ii libboost-regex-dev 1.34.1-2ubuntu1 regular expression library for C++ ii libboost-regex1.34.1 1.34.1-2ubuntu1 regular expression library for C++ I supposed that the exemple from the official website is right. So the problem must come from my configuration. I already try this compilation option : -lboostregex -lboost_regex -lboost-regex -lboost_regex_dev -lboost_regex-1_34_1 -lboost_regex-mt-d-1_34_1..... But I always get the same error. somone have an idee to resolved this problem please? Some clue...? Thanks for your attention. Zorg. _____________________________________________________________________________ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail

hallouina-ml@yahoo.fr wrote:
Hello everybody,
I begin with C++ and need to use some regex in my program. So I try to compile this example from the boost website :
http://www.boost.org/libs/regex/example/snippets/captures_example.cpp
but I get this error :
~/developpement/essai_regex/boost$ g++ -o test captures_examples.cpp
There are two issues here: in order to use that specific feature you need to compile both your code and the regex library with BOOST_REGEX_MATCH_EXTRA defined (this isn't the case for any of the other examples). You also need to specify the regex library to link against, so usually: g++ -o test -DBOOST_REGEX_MATCH_EXTRA=1 captures_examples.cpp -lboost_regex See the "repeated captures" section of the docs http://svn.boost.org/svn/boost/trunk/libs/regex/doc/html/boost_regex/capture... for more information on this still-experimental repeated-capture feature. Also note that you *do not* need to turn this feature on to be able to use regular Perl or POSIX style captures. HTH, John.

--- John Maddock
hallouina-ml@yahoo.fr wrote:
Hello everybody,
I begin with C++ and need to use some regex in my program. So I try to compile this example from the boost website :
http://www.boost.org/libs/regex/example/snippets/captures_example.cpp
but I get this error :
~/developpement/essai_regex/boost$ g++ -o test
captures_examples.cpp
There are two issues here: in order to use that specific feature you need to compile both your code and the regex library with BOOST_REGEX_MATCH_EXTRA defined (this isn't the case for any of the other examples). You also need to specify the regex library to link against, so usually:
g++ -o test -DBOOST_REGEX_MATCH_EXTRA=1 captures_examples.cpp -lboost_regex
See the "repeated captures" section of the docs
http://svn.boost.org/svn/boost/trunk/libs/regex/doc/html/boost_regex/capture...
for more information on this still-experimental repeated-capture feature.
Also note that you *do not* need to turn this feature on to be able to use regular Perl or POSIX style captures.
HTH, John.
I need Perl style capture like m/(some_regex)/g because I need the g flag (to capture more than one time my regex). So if I understand the documentation (as you can see, my english is far from beeing perfect...) ; if I want to use the g flag equivalent in my regex, I need to enable this feature. So as the documentation said, I uncomment in the user.hpp the DBOOST_REGEX_MATCH_EXTRA option and recompile it. In fact I just compile it for the first time because before I was using the boost library that was supplied by my ubuntu package. Now I get this error : ...failed updating 224 targets... ...skipped 64 targets... ...updated 4562 targets... Not all Boost libraries built properly. Why I get this error? will my boost::regex library work even if I get this error? Thanks again. _____________________________________________________________________________ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail

hallouina-ml@yahoo.fr wrote:
I need Perl style capture like m/(some_regex)/g
because I need the g flag (to capture more than one time my regex). So if I understand the documentation (as you can see, my english is far from beeing perfect...) ; if I want to use the g flag equivalent in my regex, I need to enable this feature.
Oh no you don't :-) The Perl /g flag is something different again: the equivalent functionality in Boost.Regex is regex_iterator, which enumerates one at a time over all the possible matches in a string. Repeated captures come into play when you have say an expression "(something)+" matched against "somethingsomething" in which case in Perl: $0 = "somethingsomething" $1 = "something" With BOOST_REGEX_MATCH_EXTRA enabled then $1 contains a list of all the "something"'s matched by the first capturing group within a single overall match. I hope this is clear, Regards, John Maddock.
participants (2)
-
hallouina-ml@yahoo.fr
-
John Maddock