<div class="codetitle"> <span><a style="CURSOR: pointer" data="10317" class="copybut" id="copybut10317" onclick="doCopy('code10317')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code10317"> <br>var fun = function(str){ <br>var preg = new RegExp("[\u4e00-\u9fa5]+","gi"); <br>var preg2 = new RegExp("[^\u4e00-\u9fa5]","gi"); <br>var count = 0; <br>for(var i=0;i<str.length>if(preg.test(str[i])){ <br>count = count+2; <br>}else{ <br>count = count+1; <br>} <br>} <br>return count; <br>} <br></str.length> </div>