Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the regular expressions in C++?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what are the regular expressions in C++". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought. Let's study and learn what regular expressions are in C++.

1. C regex/* write by xingming * time: 15:51:53 * for: test regex * * / # include # include using namespace std;const int times = 1000000 leading int main (int argc,char** argv) {char pattern [512] = "finance\ .sina\ .cn | stock1\ .sina\ .cn | 3G\ .sina\ .com. * (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 (& reg,pattern,REG_EXTENDED | REG_NOSUB); for (int I = 0; I < times; + + I) {for (int j = 0; j < 3; + j) {z = regexec (& reg,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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report