Email: bknpk@hotmail.com Phone: +972-54-7649119


V

 

Simple c++ exercise, which uses boost to implement regular expression replace. Similar projects can be seen at c++: main page

  1. #include <iostream>
  2. #include <string>
  3. #include <boost/regex.hpp>
  4. int main(){
  5.   std::string str = "hellooooooooo";
  6.   std::string newtext = "_\\1o";
  7.   boost::regex re("(.*[^o])[o]+");
  8.   std::cout << str << std::endl;
  9.   std::string result = boost::regex_replace(str, re, newtext);
  10.   std::cout << result << std::endl;
  11. }
  12. //g++ -g -I /usr/local/include/boost-1_33_1 boost_replace.cpp /usr/local/lib/libboost_regex-gcc-1_33_1.a
  13. //
  14. //on my debian wheezy
  15. //apt-get install libboost-all-dev
  16. //g++ -g -I /usr/local/include/boost reg_exp_b.cpp /usr/lib/libboost_regex.a

  ...


Search This Site


Feedback This Site





new pages on this site