c++正则查找

 #include <iostream>

#include <boost/regex.hpp>

using namespace std;

int main()
{
    boost::regex reg("\\{([\\w]+)\\}");
    std::string s="{afd}lookki{vvvv}kjkj{ddd}{ssss}{fddda}";
    boost::sregex_iterator end;
    for (boost::sregex_iterator it(s.begin(),s.end(),reg); it != end; it++)
    {

        cout << (*it)[0].str() << endl;
        cout << (*it)[1].str() << endl;
    }
    return 0;
}

posted @ 2012-10-12 11:29  瑞尼书苑  阅读(213)  评论(0编辑  收藏  举报