Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2007-07-06 04:32:04


Chandan Nilange wrote:
> Hello John,
>
> I tried to run the regex_search example on the page
> http://www.boost.org/libs/regex/example/snippets/regex_search_example.cpp
> with BOOST_LIB_VERSION "1_32"
>
> However, I get the following compilation error
> multiple times:
>
> /tmp/ccy6kuZL.o(.gnu.linkonce.t._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcEESaIcEEC1ES6_S6_RNS_13match_resultsIS6_S9_EERKNS_14reg_expressionIcSB_SC_EENS_15regex_constants12_match_flagsE+0x7e):
> In function
> `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char
> const*, std::basic_string<char,
> std::char_traits<char>, std::allocator<char> > >,
> std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char
> const*, std::basic_string<char,
> std::char_traits<char>, std::allocator<char> > > > >,
> boost::regex_traits<char>, std::allocator<char>
>>>> perl_matcher(__gnu_cxx::__normal_iterator<char
> const*, std::basic_string<char,
> std::char_traits<char>, std::allocator<char> > >,
> __gnu_cxx::__normal_iterator<char const*,
> std::basic_string<char, std::char_traits<char>,
> std::allocator<char> > >,
> boost::match_results<__gnu_cxx::__normal_iterator<char
> const*, std::basic_string<char,
> std::char_traits<char>, std::allocator<char> > >,
> std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char
> const*, std::basic_string<char,
> std::char_traits<char>, std::allocator<char> > > > >
>> &, boost::reg_expression<char,
> boost::regex_traits<char>, std::allocator<char> >
> const&, boost::regex_constants::_match_flags)':
>> undefined reference to `boost::reg_expression<char,
> boost::regex_traits<char>, std::allocator<char>
>>>> get_traits() const'
>
> Please help.

Those are link time messages, and crucially you've omitted the actual error!

You do sometimes get *warnings* like that if your binutils and gcc packages
are differing in versions.

> Also, could you please elaborate more on how to
> achieve overlapping matches using regex_search.

i,j; // iterators to search through
smatch what;
regex re("something");

while(regex_search(i, j, what, re) && (i != j))
{
  do_something(what);
  ++i;
}

John.


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