正则表达式-非捕获性分组

来源:互联网 发布: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)">&lt;script type="text/javascript"&gt;</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)">&lt;!--</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;msg
 = arr+"成功匹配&lt;br&gt;";</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;msg
 = "匹配失败&lt;br&gt;";</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;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)">&nbsp;</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;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)">--&gt;</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)">&lt;/script&gt;</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)">&lt;script type="text/javascript"&gt;</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)">&lt;!--</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;msg
 = arr+"成功匹配&lt;br&gt;";</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;msg
 = "匹配失败&lt;br&gt;";</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;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)">&nbsp;</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;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)">--&gt;</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)">&lt;/script&gt;</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)">&lt;script type="text/javascript"&gt;</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)">&lt;!--</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;msg
 = arr+"成功匹配&lt;br&gt;";</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;msg
 = "匹配失败&lt;br&gt;";</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;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)">&nbsp;</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)">&nbsp;</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)">&nbsp;</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)">&nbsp;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)">--&gt;</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)">&lt;/script&gt;</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>
原创粉丝点击