首页 新闻 赞助 找找看

正则表达式求解,很着急!

0
悬赏园豆:50 [已关闭问题] 关闭于 2011-06-21 23:40

string sg = "<body><D>cocoa</D><D>yyyt</D><D>ckkk</D></body>";

boost::regex reg("<body>??????????</body>");

我要提取<D></D>之间的串,一次吧三个串都提取出来,这个reg怎么设置呀??

问题补充:

解决了:

string sg = "<body><D>cocoa</D><D>yyyt</D><D>ckkk</D></body>";

boost::regex reg("<body>??????????</body>");

我要提取<D></D>之间的串,一次吧三个串都提取出来,这个reg怎么设置呀??

string::const_iterator it = sg.begin();
 string::const_iterator end = sg.end();
 boost::smatch what;

while(boost::regex_search(it,end,what,reg))
 {
  string doc = what[1];
  cout<<doc<<endl;
  it = what[0].second;
 }

x_feng的主页 x_feng | 初学一级 | 园豆:14
提问于:2011-06-21 23:08
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册