RSS
热门关键字:  虚拟主机技术  vps团购  discuz架构  虚拟主机团购  curl
当前位置 :| 团购首页>网站编程>ASP>

asp字符串操作类

来源: 作者: 时间:2008-07-28 Tag:asp   字符串   点击:

<%
class StringOperations

''****************************************************************************
'''' @功能说明: 把字符串换为char型数组
'''' @参数说明:  - str [string]: 需要转换的字符串
'''' @返回值:   - [Array] Char型数组
''****************************************************************************
public function toCharArray(byVal str)
 redim charArray(len(str))
 for i = 1 to len(str)
  charArray(i-1) = Mid(str,i,1)
 next
 toCharArray = charArray
end function

''****************************************************************************
'''' @功能说明: 把一个数组转换成一个字符串
'''' @参数说明:  - arr [Array]: 需要转换的数据
'''' @返回值:   - [string] 字符串
''****************************************************************************
public function arrayToString(byVal arr)
 for i = 0 to UBound(arr)
  strObj = strObj & arr(i)
 next
 arrayToString = strObj
end function

''****************************************************************************
'''' @功能说明: 检查源字符串str是否以chars开头
'''' @参数说明:  - str [string]: 源字符串
'''' @参数说明:  - chars [string]: 比较的字符/字符串
'''' @返回值:   - [bool]
''****************************************************************************
public function startsWith(byVal str, chars)
 if Left(str,len(chars)) = chars then
  startsWith = true
 else
  startsWith = false
 end if
end function

''****************************************************************************
'''' @功能说明: 检查源字符串str是否以chars结尾
'''' @参数说明:  - str [string]: 源字符串
'''' @参数说明:  - chars [string]: 比较的字符/字符串
'''' @返回值:   - [bool]
''****************************************************************************
public function endsWith(byVal str, chars)
 if Right(str,len(chars)) = chars then
  endsWith = true
 else
  endsWith = false
 end if
end function

''****************************************************************************
'''' @功能说明: 复制N个字符串str
'''' @参数说明:  - str [string]: 源字符串
'''' @参数说明:  - n [int]: 复制次数
'''' @返回值:   - [string] 复制后的字符串
''****************************************************************************
public function clone(byVal str, n)
 for i = 1 to n
  value = value & str
 next
 clone = value
end function

''****************************************************************************
'''' @功能说明: 删除源字符串str的前N个字符
'''' @参数说明:  - str [string]: 源字符串
'''' @参数说明:  - n [int]: 删除的字符个数
'''' @返回值:   - [string] 删除后的字符串
''****************************************************************************
public function trimStart(byVal str, n)
 value = Mid(str, n+1)
 trimStart = value
end function

''****************************************************************************
'''' @功能说明: 删除源字符串str的最后N个字符串
'''' @参数说明:  - str [string]: 源字符串
'''' @参数说明:  - n [int]: 删除的字符个数
'''' @返回值:   - [string] 删除后的字符串
''****************************************************************************
public function trimEnd(byVal str, n)
 value = Left(str, len(str)-n)
 trimEnd = value
end function

''****************************************************************************
'''' @功能说明: 检查字符character是否是英文字符 A-Z or a-z
'''' @参数说明:  - character [char]: 检查的字符
'''' @返回值:   - [bool] 如果是英文字符,返回TRUE,反之为FALSE
''****************************************************************************
public function isAlphabetic(byVal character)
 asciiValue = cint(asc(character))
 if (65 <= asciiValue and asciiValue <= 90) or (97 <= asciiValue and asciiValue <= 122) then
  isAlphabetic = true
 else
  isAlphabetic = false
 end if
end function

''****************************************************************************
'''' @功能说明: 对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


 


    由于各种原因,我们无法获知[asp字符串操作类]原创作者,如侵犯了您的版权,请您及时联系我们!
最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册