boost 字符串操作


	#include <boost/xpressive/xpressive_dynamic.hpp>
	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<<what[0]<<endl;
	cout<<what[1]<<endl;




//字符串分割


#include <boost/assign/std/vector.hpp>
#include <boost/algorithm/string.hpp>




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


string strTemp = "A B  C D E1 F1";
std::vector<string> 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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值