C++/0x02-boost
boost example2
SpeeDr00t
2016. 8. 1. 12:19
반응형
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
반응형