ASP判断只输出"英文"或"汉字"的两种方法

ASP 1676 0 2013-02-16

ASP判断只输出"英文"或"汉字"的两种方法

'判断输入语言类型,如汉字,英文等
'方法一
'tStr 传递的字符串
Function FindStr_cn_en(tStr)  
on error resume next  
if Trim(tStr)="" or IsNull(tStr)=true then   
exit function  
end if  
dim RegEx,Matches,Match,fStr  
Set RegEx=New RegExp  
RegEx.Pattern="[a-z][A-Z]*" '只显示英文字母
'RegEx.Pattern="[\W]*"       '除英文字母以外
RegEx.IgnoreCase=True  
RegEx.Global=True  
Set Matches = regEx.Execute(tStr)  
For Each Match in Matches  
fStr=fStr & Match.Value  
Next  
FindStr_cn_en=fStr  
Set RegEx=Nothing  
End Function

'方法二
'stempstr 传递的字符串
Function cnLanguge(stempstr)
returnStr=""
for i=1 to len(stempstr)
       asc_str= asc(left(stempstr,1))
      if asc_str<0 or (asc_str>=39 and asc_str<=57) and asc_str<>47 then   '以ASCⅡ码为准
       returnStr=returnStr & left(stempstr,1)  
      end   if  
      stempstr=right(stempstr,len(stempstr)-1)  
next
   cnLanguge=returnStr
End Function

上一篇:ASP过滤字符函数

下一篇:简单ASP静态生成代码

讨论数量:0

请先登录再发表讨论。 2024-04-30

天涯网魂
3 杠 5 星
TA 的文章
TA 的随言
TA 的资源链