반응형
boost example2
1.소스
#include <boost/regex.hpp> #include <iostream> #include <string> int main( int argc , char ** argv ) { std::string line; boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" ); while (std::cin) { std::getline(std::cin, line); boost::smatch matches; if (boost::regex_match(line, matches, pat)) std::cout << matches[2] << std::endl; } }
결과
hacker@ubuntu:~/cpp$ hacker@ubuntu:~/cpp$ hacker@ubuntu:~/cpp$ hacker@ubuntu:~/cpp$ c++ -I /home/hacker/boost_1_61_0 -o boost_ex02 boost_ex02.cpp /home/hacker/boost_1_61_0/stage/lib/libboost_regex.a hacker@ubuntu:~/cpp$ echo "Subject: re dfdf" | ./boost_ex02 re dfdf
반응형
'C++ > 0x02-boost' 카테고리의 다른 글
boost replace (0) | 2016.08.01 |
---|---|
boost find (0) | 2016.08.01 |
boost trimming (0) | 2016.08.01 |
boost helloworld (0) | 2016.08.01 |
boost example (0) | 2016.08.01 |