编程开发 > ASP > 文章内容

判断一个字符串里面包含有中文或者英文

2010-7-23编辑:feimeimei
  script language=vbscript
  classCNWord
  public str
  private sub Class_Initialize
  set regEx =new RegExp
  regEx.IgnoreCase = True ‘设置是否区分大小写。
  regEx.Global = True ‘设置全局可用性。
  end sub
  private regEx
  Property getCN
  dim Arr
  dim maxBound : maxBound = CNBlockCount
  redim Arr
  dim i:i=1
  For each Matchin regEx.Execute
  Arr =Match
  i = i + 1
  next
  if x=maxBound then CN = Arr
  End Property
  Property getCNcount
  ‘返回含有中文的字数
  regEx.Pattern =[“u4e00-“u9fa5]
  CNcount = findCHNnum
  End Property
  Property getCNBlockCount
  ‘返回含有中文的块数
  regEx.Pattern =[“u4e00-“u9fa5]+
  CNBlockCount = findCHNnum
  End Property
  private function findCHNnum
  findCHNnum = regEx.Execute.count
  end function
  private sub Class_Terminate
  set regEx= nothing
  end sub
  end class
  set ccc= new CNWord
  ccc.str =CNWord类引用实例,vbs
  msgbox 含有中文数 ccc.CNcount
  msgbox 含有中文块数 ccc.CNBlockCount
  msgbox 第2个中文块是- ccc.CN
  set ccc = nothing
  /script
Response对象的Cookies集合

热点推荐

登录注册
触屏版电脑版网站地图