正在阅读:ASP中一个字符串处理类加强版(VBScript)ASP中一个字符串处理类加强版(VBScript)

2004-02-14 09:33 出处:PConline 作者:asilas 责任编辑:linjixiong

    '****************************************************************************
    '' @功能说明: 对str字符串进行大小写转换
    '' @参数说明:  - str [string]: 源字符串
    '' @返回值:   - [string] 转换后的字符串
    '****************************************************************************
 public function swapCase(str)
  for i = 1 to len(str)
   current = mid(str, i, 1)
   if isAlphabetic(current) then
    high = asc(ucase(current))
    low = asc(lcase(current))
    sum = high + low
    return = return & chr(sum-asc(current))
   else
    return = return & current
   end if
  next
  swapCase = return
 end function
 
    '****************************************************************************
    '' @功能说明: 将源字符串str中每个单词的第一个字母转换成大写
    '' @参数说明:  - str [string]: 源字符串
    '' @返回值:   - [string] 转换后的字符串
    '****************************************************************************
 public function capitalize(str)
  words = split(str," ")
  for i = 0 to ubound(words)
   if not i = 0 then
    tmp = " "
   end if
   tmp = tmp & ucase(left(words(i), 1)) & right(words(i), len(words(i))-1)
   words(i) = tmp
  next
  capitalize = arrayToString(words)
 end function

    '****************************************************************************
    '' @功能说明: 将源字符Str后中的'过滤为''
    '' @参数说明:  - str [string]: 源字符串
    '' @返回值:   - [string] 转换后的字符串
    '****************************************************************************
 public function checkstr(Str)
  If Trim(Str)="" Or IsNull(str) Then
   checkstr=""
  else
   checkstr=Replace(Trim(Str),"'","''")
  end if
 End function

键盘也能翻页,试试“← →”键

关注我们

最新资讯离线随时看 聊天吐槽赢奖品