I am trying to replace the multicharacters in a string using std::tr1::regex as I am not able to find any function that can help to replace them. The code is as below:
// Example program
#include <iostream>
#include <string>
#include <tr1/regex>
void f1()
{
std::string str = "ÿûABC";
std::tr1::regex rx("ÿû");
std::string replacement = "";
std::tr1::regex_replace(str,rx,replacement);
}
int main()
{
f1();
return 0;
}
But I am receiving the below compilation error. Could anyone please suggest if there is any to resolve it or any better option to replace them using C++98?
In file included from 4:0: /usr/include/c++/4.9/tr1/regex:2407:5: warning: inline function '_Out_iter std::tr1::regex_replace(_Out_iter, _Bi_iter, _Bi_iter, const std::tr1::basic_regex&, const std::basic_string&, std::tr1::regex_constants::match_flag_type) [with _Out_iter = std::back_insert_iterator >; _Bi_iter = __gnu_cxx::__normal_iterator >; _Rx_traits = std::tr1::regex_traits; _Ch_type = char; std::tr1::regex_constants::match_flag_type = std::bitset]' used but never defined regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last, ^ /tmp/ccGJXgKd.o: In function `f1()': :(.text+0x81): undefined reference to `std::tr1::basic_regex >::_M_compile()' :(.text+0xc5): undefined reference to `std::back_insert_iterator std::tr1::regex_replace, __gnu_cxx::__normal_iterator, std::tr1::regex_traits, char>(std::back_insert_iterator, __gnu_cxx::__normal_iterator, __gnu_cxx::__normal_iterator, std::tr1::basic_regex > const&, std::basic_string, std::allocator > const&, std::bitset)' collect2: error: ld returned 1 exit status