(加强)(VBScript)ASP中一个字符串处理类

ASP中一个字符串处理类(加强)(VBScript) 
文章出处:联动天下 作者:联动天下 发布时间:2005-12-21 
相关文章参见:

http://www.csdn.net/Develop/read_article.asp?id=22695

本文在此基础上进行了一些添加,加了几个适合中文网站的FUNCTION进去,可能还有些没有补充进去,有感兴趣的朋友可以再在此基础上加一点FUNCTION进去,不过可别忘记分享一下!

<% 
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 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值