正则表达式-非捕获性分组
来源:互联网 发布:vb控制台应用程序 编辑:程序博客网 时间:2024/06/10 16:49
<div id="article_content" class="article_content tracking-ad" data-mod="popu_307" data-dsm="post">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">非捕获性分组语法为(?:pattern),即将pattern部分组合成一个可统一操作的组合项,但不把这部分内容当作子匹配捕获,匹配的内容部进行编号也不存储在缓冲区中供以后使用。非捕获性分组方法在必须进行组合、但又不想对组合的部分进行缓存的情况下非常有用。</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">例如,要在一篇英文资料中查找"program"和"project"两个单词,正则表达式可表示为/program|project/,也可表示为/pro(gram|ject)/,但是缓存子匹配(gramject)没有意义,就可以用/pro(?:gram|ject)/进行非捕获性匹配这样既可以简洁匹配又可不缓存无实际意义的字匹配。</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="word-wrap:normal; word-break:normal; line-height:21px; color:rgb(50,62,50); font-family:simsun; font-size:14px; background-color:rgb(243,243,243)"><strong>实例:</strong></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><script type="text/javascript"></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><!--</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var str = "program,a good project";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var reg = /program|project/g;</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var arr = reg.exec(str);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var msg;</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">if(arr){</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= arr+"成功匹配<br>";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}else{</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= "匹配失败<br>";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">document.write(msg);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">arr = reg.exec(str);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">if(arr){</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= arr+"成功匹配";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}else{</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= "匹配失败";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">document.write(msg);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">--></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"></script></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="word-wrap:normal; word-break:normal; line-height:21px; color:rgb(50,62,50); font-family:simsun; font-size:14px; background-color:rgb(243,243,243)"><strong>输出:</strong></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">program成功匹配</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">project成功匹配</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">-----------------------------------------------------------------------------------------------------------------</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="word-wrap:normal; word-break:normal; line-height:21px; color:rgb(50,62,50); font-family:simsun; font-size:14px; background-color:rgb(243,243,243)"><strong>实例:</strong></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><script type="text/javascript"></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><!--</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var str = "program,a good project";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var reg = /pro(gram|ject)/g;</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var arr = reg.exec(str);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var msg;</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">if(arr){</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= arr+"成功匹配<br>";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}else{</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= "匹配失败<br>";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">document.write(msg);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">arr = reg.exec(str);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">if(arr){</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= arr+"成功匹配";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}else{</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= "匹配失败";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">document.write(msg);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">--></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"></script></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="word-wrap:normal; word-break:normal; line-height:21px; color:rgb(50,62,50); font-family:simsun; font-size:14px; background-color:rgb(243,243,243)"><strong>输出:</strong></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">program,gram成功匹配</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">project,ject成功匹配</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">-----------------------------------------------------------------------------------------------------------------</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="word-wrap:normal; word-break:normal; line-height:21px; color:rgb(50,62,50); font-family:simsun; font-size:14px; background-color:rgb(243,243,243)"><strong>实例:</strong></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><script type="text/javascript"></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><!--</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var str = "program,a good project";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var reg = /pro(?:gram|ject)/g;</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var arr = reg.exec(str);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var msg;</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">if(arr){</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= arr+"成功匹配<br>";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}else{</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= "匹配失败<br>";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">document.write(msg);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">arr = reg.exec(str);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">if(arr){</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= arr+"成功匹配";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}else{</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= "匹配失败";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">document.write(msg);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">--></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"></script></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="word-wrap:normal; word-break:normal; line-height:21px; color:rgb(50,62,50); font-family:simsun; font-size:14px; background-color:rgb(243,243,243)"><strong>输出:</strong></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">program成功匹配</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">project成功匹配</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<br>
</div>
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">非捕获性分组语法为(?:pattern),即将pattern部分组合成一个可统一操作的组合项,但不把这部分内容当作子匹配捕获,匹配的内容部进行编号也不存储在缓冲区中供以后使用。非捕获性分组方法在必须进行组合、但又不想对组合的部分进行缓存的情况下非常有用。</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">例如,要在一篇英文资料中查找"program"和"project"两个单词,正则表达式可表示为/program|project/,也可表示为/pro(gram|ject)/,但是缓存子匹配(gramject)没有意义,就可以用/pro(?:gram|ject)/进行非捕获性匹配这样既可以简洁匹配又可不缓存无实际意义的字匹配。</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="word-wrap:normal; word-break:normal; line-height:21px; color:rgb(50,62,50); font-family:simsun; font-size:14px; background-color:rgb(243,243,243)"><strong>实例:</strong></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><script type="text/javascript"></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><!--</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var str = "program,a good project";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var reg = /program|project/g;</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var arr = reg.exec(str);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var msg;</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">if(arr){</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= arr+"成功匹配<br>";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}else{</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= "匹配失败<br>";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">document.write(msg);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">arr = reg.exec(str);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">if(arr){</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= arr+"成功匹配";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}else{</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= "匹配失败";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">document.write(msg);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">--></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"></script></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="word-wrap:normal; word-break:normal; line-height:21px; color:rgb(50,62,50); font-family:simsun; font-size:14px; background-color:rgb(243,243,243)"><strong>输出:</strong></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">program成功匹配</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">project成功匹配</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">-----------------------------------------------------------------------------------------------------------------</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="word-wrap:normal; word-break:normal; line-height:21px; color:rgb(50,62,50); font-family:simsun; font-size:14px; background-color:rgb(243,243,243)"><strong>实例:</strong></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><script type="text/javascript"></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><!--</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var str = "program,a good project";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var reg = /pro(gram|ject)/g;</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var arr = reg.exec(str);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var msg;</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">if(arr){</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= arr+"成功匹配<br>";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}else{</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= "匹配失败<br>";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">document.write(msg);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">arr = reg.exec(str);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">if(arr){</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= arr+"成功匹配";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}else{</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= "匹配失败";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">document.write(msg);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">--></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"></script></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="word-wrap:normal; word-break:normal; line-height:21px; color:rgb(50,62,50); font-family:simsun; font-size:14px; background-color:rgb(243,243,243)"><strong>输出:</strong></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">program,gram成功匹配</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">project,ject成功匹配</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">-----------------------------------------------------------------------------------------------------------------</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="word-wrap:normal; word-break:normal; line-height:21px; color:rgb(50,62,50); font-family:simsun; font-size:14px; background-color:rgb(243,243,243)"><strong>实例:</strong></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><script type="text/javascript"></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><!--</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var str = "program,a good project";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var reg = /pro(?:gram|ject)/g;</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var arr = reg.exec(str);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">var msg;</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">if(arr){</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= arr+"成功匹配<br>";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}else{</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= "匹配失败<br>";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">document.write(msg);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">arr = reg.exec(str);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">if(arr){</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= arr+"成功匹配";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}else{</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> </span><wbr style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"><span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"> msg
= "匹配失败";</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">}</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">document.write(msg);</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">--></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)"></script></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="word-wrap:normal; word-break:normal; line-height:21px; color:rgb(50,62,50); font-family:simsun; font-size:14px; background-color:rgb(243,243,243)"><strong>输出:</strong></span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">program成功匹配</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<span style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">project成功匹配</span><br style="color:rgb(50,62,50); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(243,243,243)">
<br>
</div>
阅读全文
0 0
- 正则表达式 非捕获性分组
- 正则表达式-非捕获性分组
- javascript正则表达式分组-捕获性分组/非捕获性分组/正则前瞻
- JavaScript正则表达式分组模式:捕获性分组与非捕获性分组及前瞻
- 正则表达式捕获分组
- 【JavaScript 学习--01】--正则表达式的正则前瞻(?=)和非捕获性分组(?:)区别
- javascript正则表达式:非捕获分组的一个使用例子
- 正则表达式之捕获型分组与非捕获型分组
- 正则表达式--非捕获
- 正则表达式分组捕获说明
- 正则表达式- 捕获组 非捕获组
- 正则表达式中的捕获和非捕获
- 正则表达式中的捕获和非捕获
- java 高级正则表达式 分组 捕获 引用
- 正则表达式 分组捕获(反向引用)
- 正则表达式高级用法(分组与捕获)
- 正则表达式之二——捕获组、非捕获组、环视、固化分组、反向引用、回溯
- 正则表达式特殊构造(非捕获)
- CF816E,奇技淫巧的复杂度分析
- 【妄言之言】致二十四岁的自己
- css导航栏
- 浏览器对象模型BOM总结
- 计算几何——多边形 计算几何误差修正
- 正则表达式-非捕获性分组
- tomcat启动闪退
- linux常用操作-1.获得帮助,使用man page
- 批量微信过滤软件 开通微信号码筛选
- Ubuntu14.04升级CMake
- 函数作用域和作用域链
- 【Lua】require 的使用
- Java for Web学习笔记(七一):Service和Repository(6)在Spring框架中使用Listener
- HTML基础知识