Well first of all thank you for the very professional opinion. I installed the boost.regex library but got problems compiling c++ code which uses it. I used the following command to compile my code
Code:
g++ -o ZZ test.cpp –I/home/boost/boost_1_45_0/libs/regex/build/gcc/boost_regex-gcc-1_45/ -L/home/boost/boost_1_45_0/libs/regex/build/gcc/libboost_regex-gcc-1_45.a
In short I am giving the paths to de library and the includes . However it does not run. The actual code i compile is : (code downloaded form the internet)
Code:
#include <iostream>
#include <string>
#include <boost/regex.hpp>
using namespace std;
int main( ) {
std::string s, sre;
boost::regex re;
while(true)
{
cout << "Expression: ";
cin >> sre;
if (sre == "quit")
{
break;
}
cout << "String: ";
cin >> s;
try
{
// Set up the regular expression for case-insensitivity
re.assign(sre, boost::regex_constants::icase);
}
catch (boost::regex_error& e)
{
cout << sre << " is not a valid regular expression: \""
<< e.what() << "\"" << endl;
continue;
}
if (boost::regex_match(s, re))
{
cout << re << " matches " << s << endl;
}
}
}
Does anyone knows why this does not work?
The actual error reads as follows
Code:
ccYuUtqf.o: In function `boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::assign(char const*, char const*, unsigned int)':
test.cpp:(.text._ZN5boost11basic_regexIcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE6assignEPKcS7_j[boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits'
/home/tmp/ccYuUtqf.o: In function `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator:
test.cpp:(.text._ZN5boost9re_detail12perl_matcherIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS6_EEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEC1ES6_S6_RNS_13matc'
/home/tmp/ccYuUtqf.o:(.gcc_except_table+0xa4): undefined reference to `typeinfo for boost::regex_error'
/home/tmp/ccYuUtqf.o: In function `bool boost::regex_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> :
test.cpp:(.text._ZN5boost11regex_matchIN9__gnu_cxx17__normal_iteratorIPKcSsEESaINS_9sub_matchIS5_EEEcNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEEEbT_SD_RNS_13match_resultsISD'
collect2: ld returned 1 exit status