boost正则表达式多次匹配

 

 #include "stdafx.h"
#include <cstdlib>
#include <stdlib.h>
#include <boost/regex.hpp>
#include <string>
#include <iostream>

using namespace std;
using namespace boost;

regex reg("a(\\d*)b");

int main(int argc, char* argv[])
{
    string in;
    cmatch what;
    cout << "enter test string" << endl;
    getline(cin,in);
    sregex_token_iterator it( in.begin(), in.end(), reg, 1 );
    sregex_token_iterator end;

    while ( it != end )
    {
        cout << ( *it++ ) << endl;
    }

    system( "pause" );
    return 0;
}

posted @ 2009-07-05 15:09  冷寒生  阅读(565)  评论(0编辑  收藏  举报
IT知识库