#include <boost/algorithm/string.hpp>
#include <string>
#include <boost/algorithm/string_regex.hpp>
#include <iostream>
using namespace std;
using namespace boost;
bool is_exec_filename(string& filename)
{
return iends_with(filename,".exe") || iends_with(filename,".com");
}
int main()
{
string str1(" hello world");
to_upper(str1);
string str2;
cout << to_lower_copy(str1)<<endl;
cout << str1 << endl;
trim(str1);
cout << str1 << endl;
string filename("a.exe");
cout<<"a.exe" << (is_exec_filename(filename) ? "is" : "is not") << "exe filename\n";
string text("thisistest");
cout <<(all(text, is_lower())?" is lower":" is not lower") << endl;
//字符串的裁剪
string str3(" hello world ");
cout<<trim_left_copy(str3) << endl;
cout<<trim_right_copy(str3) << endl;
trim(str3);
cout << str3<<endl;
string phone("0086054487653421");
cout << trim_left_copy_if(phone,is_any_of("0")) << endl;
trim_if(phone,is_any_of("0"));
cout << phone << endl;
return 0;
}
boost之字符串算法庫
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.