Posted in Javascript onJanuary 24, 2014
var fun = function(str){ var preg = new RegExp("[\u4e00-\u9fa5]+","gi"); var preg2 = new RegExp("[^\u4e00-\u9fa5]","gi"); var count = 0; for(var i=0;i<str.length;i++){ if(preg.test(str[i])){ count = count+2; }else{ count = count+1; } } return count; }
js关于字符长度限制的问题示例探讨
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@