반응형
boost c++ 라이브러리 사용하기 ][ find iterator
■ find iterator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <boost/algorithm/string.hpp> | |
#include <iostream> | |
using namespace std; | |
using namespace boost; | |
int main( int argc , char ** argv ) | |
{ | |
string str1 = "hello black falcon ab-*-AB-*-aB"; | |
typedef find_iterator<string::iterator> string_find_it; | |
string_find_it find_it; | |
for( find_it = make_find_iterator(str1, first_finder("ab", is_iequal())); | |
find_it != string_find_it(); | |
find_it++) | |
{ | |
cout << copy_range<std::string>(*find_it) << endl; | |
} | |
typedef split_iterator< string::iterator > string_split_it; | |
string_split_it split_it; | |
for( split_it = make_split_iterator(str1, first_finder("-*-", is_iequal())); | |
split_it != string_split_it(); | |
split_it++) | |
{ | |
cout << copy_range<std::string>(*split_it) << endl; | |
} | |
} |
■ 실행결과
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hacker@ubuntu:~/cpp$ | |
hacker@ubuntu:~/cpp$ | |
hacker@ubuntu:~/cpp$ | |
hacker@ubuntu:~/cpp$ c++ -I /home/hacker/boost_1_61_0 -o boost_find2 boost_find2.cpp | |
hacker@ubuntu:~/cpp$ | |
hacker@ubuntu:~/cpp$ | |
hacker@ubuntu:~/cpp$ ./boost_find2 | |
ab | |
AB | |
aB | |
hello black falcon ab | |
AB | |
aB | |
hacker@ubuntu:~/cpp$ |
반응형
'C++ > 0x02-boost' 카테고리의 다른 글
boost to_upper_copy (0) | 2016.08.01 |
---|---|
boost iterator_range (0) | 2016.08.01 |
boost replace (0) | 2016.08.01 |
boost find (0) | 2016.08.01 |
boost trimming (0) | 2016.08.01 |