Simple c++ exercise, which uses boost
to implement regular expression replace.
Similar projects can be seen at c++:
main page
- #include <iostream>
- #include <string>
- #include <boost/regex.hpp>
- int main(){
- std::string str = "hellooooooooo";
- std::string newtext = "_\\1o";
- boost::regex re("(.*[^o])[o]+");
- std::cout << str << std::endl;
- std::string result = boost::regex_replace(str, re, newtext);
- std::cout << result << std::endl;
- }
- //g++ -g -I /usr/local/include/boost-1_33_1 boost_replace.cpp /usr/local/lib/libboost_regex-gcc-1_33_1.a
- //
- //on my debian wheezy
- //apt-get install libboost-all-dev
- //g++ -g -I /usr/local/include/boost reg_exp_b.cpp /usr/lib/libboost_regex.a
|