
After downloading boost_1_33_1, I succeeded in building regex lib with both
VC8 and GCC 3.4.2(mingw special)
1st:
The following code, which is compiled ok using VC8 (cl
a.cpp/I"F:\boost_1_33_1" /EHsc), gives out wrong answer.
Well I think the answer is wrong. Do I misunderstand the regular expression?
It says"no match" while it is supposed to match twice. 01234 and 56972.
If I changes the regex expr to ".*", the code functions well and gives out:
The (0) match is:01234abcd56972
//==================CODE================
#include <string>
#include
(ch ar const*, char const*, boost::match_results
> >&, boost::basic_regex > const&, boost::regex_constants::_match_flags)] +0x9a):reg.cpp: undefined reference to `boost::re_detail::perl_matcher >, boost::regex_traits >::match()' C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/cccPaaaa.o(.text$_ZN5boost9re_detail12perl_ma tcherIPKcSaINS_9sub_matchIS3_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEC 1ES3_S3_RNS_13match_resultsIS3_S6_EERKNS_11basic_regexIcSA_EENS_15regex_constant s12_match_flagsES3_[boost::re_detail::perl_matcher >, boost::regex_traits >::perl_matcher(char const*, char const*, boost::match_results > >&, boost::basic_regex > const&, boost::reg ex_constants::_match_flags, char const*)]+0xec):reg.cpp: undefined reference to `boost::re_detail::perl_matcher >, boost::regex_traits ::constr uct_init(boost::basic_regex > const&, boost::regex_constants::_match_flags)' C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/cccPaaaa.o(.text$_ZN5boost11basic_regexIcNS_1 2regex_traitsIcNS_16cpp_regex_traitsIcEEEEE6assignEPKcS7_j[boost::basic_regex >::assign(char con st*, char const*, unsigned int)]+0x22):reg.cpp: undefined reference to `boost::b asic_regex ::do _assign(char const*, char const*, unsigned int)'
collect2: ld returned 1 exit status
------------------error message under Linux:-------------------------
[root@FC5 project]g++ a.cpp -I"/usr/include" -o a.o
/tmp/cczdwrqd.o: In function `boost::basic_regex
::perl_matcher(char const*, char const*, boost::match_results
> >&, boost::basic_regex > const&, boost::regex_constants::_match_flags, char const*)]+0xa5):undefined reference to'boost::re_detail::perl_matcher >, boost::regex_traits >::construct_init(boost::basic_regex > const&, boost::regex_constants::_match_flags)' /tmp/cczdwrqd.o: In function `bool boost::regex_match >, char, boost::regex_traits >(char const*, char const*, boost::match_results > >&, boost::basic_regex > const&, boost::regex_constants::_match_flags)':reg.cpp:(.text._ZN5boost11regex_matchIPKcSaINS_9sub_matchIS2_EEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEbT_SA_RNS_13match_resultsISA_T0_EERKNS_11basic_regexIT1_T2_EENS_15regex_constants12_match_flagsE[bool boost::regex_match , char, boost::regex_traits >(char const*, char const*, boost::match_results > >&, boost::basic_regex > const&, boost::regex_constants::_match_flags)]+0x46):undefined reference to'boost::re_detail::perl_matcher >, boost::regex_traits >::match()'
collect2: ld returns 1
Can some help me? Although I know the question above may seem stupid and easy to solve. //Thanks -- This is my Very Signature. Ha, pretty good?

Renjie Zhao wrote:
After downloading boost_1_33_1, I succeeded in building regex lib with both VC8 and GCC 3.4.2(mingw special)
1st: The following code, which is compiled ok using VC8 (cl a.cpp/I"F:\boost_1_33_1" /EHsc), gives out wrong answer. Well I think the answer is wrong. Do I misunderstand the regular expression? It says"no match" while it is supposed to match twice. 01234 and 56972. If I changes the regex expr to ".*", the code functions well and gives out: The (0) match is:01234abcd56972
What is the problem?
You're doing two things completely wrong: 1) regex_match will find one match only if it is a match against the *whole of the supplied string*. To find a match against a sub-set of the supplied string use regex_search. 2) The match_results structure contains matches for *marked sub-expressions*, only one match is found with regex_search/regex_match. To find multiple matches you iterate through them with regex_iterator or regex_token_iterator.
2nd: I got a lot of error messages when I tried to compile the same piece of code with GCC 3.4.2 (mingw-special) under windows 2003 and GCC 4.1.0-3 (shipped with Fedora Core 5) under Linux. The previous work using Boost::regex is to build the lib, under windows and linux, the work is done with no error.
------------------error message under windows:------------------------- F:\projects> g++ a.cpp -I"F:\boost_1_33_1" -o a.exe
You haven't supplied a regex lib to link against. Consult your gcc manual for that one. John.
participants (2)
-
John Maddock
-
Renjie Zhao