#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之字符串算法库
最新推荐文章于 2021-10-30 12:52:53 发布