如何判斷字符串中有多少漢字代碼實例:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>標題頁</title>
</head>
<body>
<script language="JavaScript"> 
function cal(str)
{ 
    re=/[\u4E00-\u9FA5]/g;  //測試中文字符的正則
    if(re.test(str))        //使用正則判斷是否存在中文
    return str.match(re).length //返回中文的個數
    else 
    return 0 
} 
</script> 
<input onBlur="alert(cal(this.value))"></body> 
</body>
</html>