当前位置: 首页 > news >正文

会网站建设如何找工作互联网营销行业

会网站建设如何找工作,互联网营销行业,自己做网站怎么跳过备案,电子商务网站软件建设核心文章目录1. 查找第一个匹配的2. 查找所有结果3. 打印匹配结果的上下文4. 使用子表达式5. 查找并替换注意: .#xff08;点#xff09;在括号中没有特殊含义#xff0c;无需转义用\转义。 1. 查找第一个匹配的 #include iostream #include regexusing names… 文章目录1. 查找第一个匹配的2. 查找所有结果3. 打印匹配结果的上下文4. 使用子表达式5. 查找并替换注意: .点在括号中没有特殊含义无需转义用\转义。 1. 查找第一个匹配的 #include iostream #include regexusing namespace std;int main(void) {string pattern [^c]ei;pattern [[:alpha:]]* pattern [[:alpha:]]*;regex policy(pattern); string text receipt freind theif receive;smatch results;if(regex_search(text, results, policy))cout results.str() endl; }输出结果 freind2. 查找所有结果 #include iostream #include regexusing namespace std;int main (void) {string pattern [^c]ei;pattern [[:alpha:]]* pattern [[:alpha:]]*;// 忽略大小写regex policy (pattern, regex::icase);string text receipt freind theif receive;for (sregex_iterator it (text.begin(), text.end(), policy), end_it;it ! end_it; it)cout it-str() endl; }其中比较难理解的是sregex_iterator it (text.begin(), text.end(), policy), end_it这行代码是定义了it迭代器来进行遍历查询end_it为空sregex_iterator起到尾后迭代器的作用。 输出结果 freind theif3. 打印匹配结果的上下文 #include iostream #include regexusing namespace std;string text Once there were two mice. They were friends. One mouse lived in the country; the other mouse lived in the city.After many years the Country mouse saw the City mouse;he said, \Do come and see me at my house in the country.\ So the City mouse went. The City mouse said, \This foodis not good, and your house is not good. Why do you live in a hole in the field? You should come and live in the city. You would live in a nice house made of stone. You would have nice food to eat. You must come and see me atmy house in the city.\The Country mouse went to the houseof the City mouse. It was a very good house. Nice food was set ready for them to eat. But just as they began toeat they heard a great noise. The City mouse cried, \ Run! Run! The cat is coming!\ They ran away quickly and hid.After some time they came out. When they came out, the Country mouse said, \I do not like living in the city.I like living in my hole in the field. For it is nicerto be poor and happy, than to be rich and afraid.;int main (void) {string pattern you;pattern [[:alpha:]]* pattern [[:alpha:]]*;regex policy (pattern, regex::icase);for (sregex_iterator it (text.begin(), text.end(), policy), end_it;it ! end_it ; it) {auto pos it-prefix().length();pos pos 40 ? pos - 40 : 0;cout it-prefix().str().substr (pos) \n\t\t it-str() \n it-suffix().str().substr (0, 40) endl;}}输出结果 mouse said, This foodis not good, and your house is not good. Why do you live in ahouse is not good. Why do you live in a hole in the field? You shouldlive in a hole in the field? You should come and live in the city. You wshould come and live in the city. You would live in a nice house made of ston uld live in a nice house made of stone. You would have nice food to eat. You must cwould have nice food to eat. You must come and see me atmy house in the 4. 使用子表达式 #include iostream #include regexusing namespace std;string text Once there were two mice. They were friends. One mouse lived in the country; the other mouse lived in the city.After many years the Country mouse saw the City mouse;he said, \Do come and see me at my house in the country.\ So the City mouse went. The City mouse said, \This foodis not good, and your house is not good. Why do you live in a hole in the field? You should come and live in the city. You would live in a nice house made of stone. You would have nice food to eat. You must come and see me atmy house in the city.\The Country mouse went to the houseof the City mouse. It was a very good house. Nice food was set ready for them to eat. But just as they began toeat they heard a great noise. The City mouse cried, \ Run! Run! The cat is coming!\ They ran away quickly and hid.After some time they came out. When they came out, the Country mouse said, \I do not like living in the city.I like living in my hole in the field. For it is nicerto be poor and happy, than to be rich and afraid.;int main (void) {string pattern ! The (.*?)(coming)[[:alnum:]]*;regex policy (pattern);for (sregex_iterator it (text.begin(), text.end(), policy), end_it; it ! end_it ; it) {cout 总表达式\n\t it-str() \n;if ( (*it) [1].matched)cout 第1个子表达式\n\t it-str (1) \n;if ( (*it) [2].matched)cout 第2个子表达式\n\t it-str (2);}}输出结果 总表达式! The cat is coming 第1个子表达式cat is 第2个子表达式coming5. 查找并替换 regex_replace()用于查找并替换 #include iostream #include regex #include sstreamusing namespace std;static const string text morgan (201) 555-2368 862-555-0123\ndrew (973)555.0130\nlee (609) 555-0132 2015550175 800.555-0000; int main (void) {string phone_pattern (\\()? //可选左括号(\\d{3}) //区号(\\))? //可选右括号([-. ])? //可选分隔符(\\d{3}) //前三位([-. ])? //可选分隔符(\\d{4}); //后四位regex policy (phone_pattern);string format $2.$5.$7;//格式为 xxx.xxx.xxxxistringstream input (text);string line;while (getline (input, line)) {cout regex_replace (line, policy, format) endl;} }运行结果 morgan 201.555.2368 862.555.0123 drew 973.555.0130 lee 609.555.0132 201.555.0175 800.555.0000其中format中的$n表示第n个子表达式。 默认情况下regex_replace会输出整个输入序列。 未与正则表达式匹配的部分会原样输出匹配的部分按照格式字符来输出。 如果只想要匹配的部分我们可以通过添加format_no_copy标志 string fmt $2.$5.$7 cout regex_replace (line, policy, format, regex_constants::format_no_copy) endl;此时输出结果 201.555.2368 862.555.0123 973.555.0130 609.555.0132 201.555.0175 800.555.0000 标准库定义了用来在替换过程中控制匹配或格式的标志。这些标志可以传递给函数regex_search或regex_match或是类smatch的format成员例如format_no_copy是类型match_flag_type的值定义在命名空间std::regex_constants中。 匹配标志定义在regex_constants::mat_flag_type中 match_default等价于format_defaultmatch_not_bol不将首字符作为行首处理match_not_eol不将尾字符作为行尾处理match_not_bow不将首字符作为单词首处理match_not_eow不将尾字符作为单词尾处理match_any如果存在多于一个匹配则可返回任意一个匹配match_not_null不匹配任何空序列match_continuous匹配必须从输入的首字符开始match_prev_avail输入序列包含第一个匹配之前的内容format_default用ECMAScript规则替换字符串format_sed用POSIX sed规则替换字符串format_no_copy不输出输入序列中未匹配的部分format_first_only只替换子表达式的第一次出现 参考书籍 C Primer 5 中文版
http://www.ho-use.cn/article/10813964.html

相关文章:

  • 平安网站建设工作总结国外空间
  • 郑州做网站公司yooker广告策划方案怎么做
  • 黑龙江省垦区建设协会网站建一个小型购物网站要有服务器
  • 需要网站建设企业建设网站哪里好
  • 张家港快速网站建设手机网页链接制作生成
  • 无锡网站优化价格vue大型网站开发吗
  • 用j2ee作的网站建设部网站投诉核查
  • asp在网站制作中的作用那个网站做租赁好
  • 甜品网站建设项目规划书翻译建设企业网站
  • 做淘宝的网站的多少钱公司网站建设怎么做
  • 个人网站名可以和别人一样吗北京商城网站开发公司
  • 服装图案素材网站php网站开发实例教程实验报告
  • 做任务用手机号登录网站上海seo推广公司
  • 中小型企业网站建设企业自建站运营
  • 南京网站建设 小程序推动高质量发展发言材料
  • 网站返回按钮设计广州市越秀区建设局网站
  • 中国建设银行的网站用户名是什么意思温州推广平台
  • 公司内部网站建设管理办法六安网站建设企业
  • 做网站去什么公司阿里云 wordpress 博客
  • 环保工程东莞网站建设wordpress 中文网站
  • 自动搭建网站源码沙田镇网站建设公司
  • 广州做网站的网络公司类似谷德设计网的网站
  • 找兼职h5网站开发人员淘宝做网站的
  • 东莞好的网站建设哪家好多少网站域名采用中文
  • 网站开发亿码酷技术苏州网站建设丶好先生科技
  • 2_ 如何写一份详细的网站开发方案wordpress 自动发货插件
  • 网站优化技术在哪个网站做失业分解
  • iis怎么添加网站贵阳市住房和城乡建设局政务网站
  • 电商平台如何引流推广奢侈品网站怎么做tuig优化
  • 阅读网站模板下载网站建设服务好