boost 字符串操作


	#include 
	using namespace std;
            using namespace boost::xpressive;
	
	//正则表达式
	
	cregex reg = cregex::compile("\\d+",icase);
	assert(regex_match("12",reg));
	boost::xpressive::cmatch what;
	regex_search("1a2,3f",what,reg);
	assert(what.size());

	cout<




//字符串分割


#include
#include




int _tmain(int argc, _TCHAR* argv[])
{


string strTemp = "A B  C D E1 F1";
std::vector d;
boost::algorithm::split(d,strTemp,boost::algorithm::is_any_of(" "),boost::algorithm::token_compress_on); //默认参数是 boost::token_compress_off (srTemp  分隔后就是 A B 空 C E1 F1  )
getchar();
return 0;
}






//boost 格式化字符串
方式一  :
cout << boost::format("%s") % "输出内容" << endl;   


方式二 : 
std::string s;  s = str( boost::format("%s") % "输出内容" ); 
    cout << s << endl;   
 
 
方式三 :
   boost::format formater("%s");  formater % "输出内容";  
   std::string s = formater.str();  cout << s << endl;  
   
方式四 : 
    cout << boost::format("%1%") % boost::io::group(hex, showbase, 40) << endl


你可能感兴趣的:(boost,c++,正则表达式,iterator,algorithm,regex,search)