C++中正则表达式有哪些-成都快上网建站

C++中正则表达式有哪些

这篇文章主要讲解了“C++中正则表达式有哪些”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“C++中正则表达式有哪些”吧!

创新互联建站科技有限公司专业互联网基础服务商,为您提供四川绵阳服务器托管高防物理服务器租用,成都IDC机房托管,成都主机托管等互联网服务。

1、C regex

/*  write by xingming  *  time:2012年10月19日15:51:53  *  for: test regex  *  */#include #include #include #include #include #include using namespace std;const int times = 1000000;int main(int argc,char** argv) {char pattern[512]="finance\.sina\.cn|stock1\.sina\.cn|3g\.sina\.com\.cn.*(channel=finance|_finance$|ch=stock|/stock/)|dp.sina.cn/.*ch=9&";const size_t nmatch = 10;regmatch_t pm[10];int z ;regex_t reg;char lbuf[256]="set",rbuf[256];char buf[3][256] = {"finance.sina.cn/google.com/baidu.com.google.sina.cndddddddddddddddddddddda.sdfasdfeoasdfnahsfonadsdf","3g.com.sina.cn.google.com.dddddddddddddddddddddddddddddddddddddddddddddddddddddbaidu.com.sina.egooooooooo","http://3g.sina.com.cn/google.baiduchannel=financegogo.sjdfaposif;lasdjf.asdofjas;dfjaiel.sdfaosidfj"};printf("input strings:\n");
    timeval end,start;
    gettimeofday(&start,NULL);
    regcomp(®,pattern,REG_EXTENDED|REG_NOSUB);for(int i = 0 ; i < times; ++i)
    {for(int j = 0 ; j < 3; ++j)
        {
            z = regexec(®,buf[j],nmatch,pm,REG_NOTBOL);/*          if(z==REG_NOMATCH)                 printf("no match\n");             else                 printf("ok\n");                 */}
    }
    gettimeofday(&end,NULL);
    uint time = (end.tv_sec-start.tv_sec)*1000000 + end.tv_usec - start.tv_usec;cout<
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流