闽ゅ彻把ǎ
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
'****************************************************************************
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
'****************************************************************************
'' @弧: 盢方才﹃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
'****************************************************************************
'' @弧: 盢才﹃いstrいHTML絏秈︽筁耾
'' @把计弧: - str [string]: 方才﹃
'' @: - [string] 锣传才﹃
'****************************************************************************
Public Function HtmlEncode(str)
If Trim(Str)="" Or IsNull(str) then
HtmlEncode=""
else
str=Replace(str,">",">")
str=Replace(str,"<","<")
str=Replace(str,Chr(32)," ")
str=Replace(str,Chr(9)," ")
str=Replace(str,Chr(34),""")
str=Replace(str,Chr(39),"'")
str=Replace(str,Chr(13),"")
str=Replace(str,Chr(10) & Chr(10), "</p><p>")
str=Replace(str,Chr(10),"<br> ")
HtmlEncode=str
end if
End Function
'****************************************************************************
'' @弧: 璸衡方才﹃Str(いゅ才2竊)
'' @把计弧: - str [string]: 方才﹃
'' @: - [Int] 方才﹃
'****************************************************************************
Public Function strLen(Str)
If Trim(Str)="" Or IsNull(str) Then
strlen=0
else
Dim P_len,x
P_len=0
StrLen=0
P_len=Len(Trim(Str))
For x=1 To P_len
If Asc(Mid(Str,x,1))<0 Then
StrLen=Int(StrLen) + 2
Else
StrLen=Int(StrLen) + 1
End If
Next
end if
End Function
'****************************************************************************
'' @弧: 篒方才﹃Str玡LenNum才(いゅ才2竊)
'' @把计弧: - str [string]: 方才﹃
'' @把计弧: - LenNum [int]: 篒
'' @: - [string]: 锣传才﹃
'****************************************************************************
Public Function CutStr(Str,LenNum)
Dim P_num
Dim I,X
If StrLen(Str)<=LenNum Then
Cutstr=Str
Else
P_num=0
X=0
Do While Not P_num > LenNum-2
X=X+1
If Asc(Mid(Str,X,1))<0 Then
P_num=Int(P_num) + 2
Else
P_num=Int(P_num) + 1
End If
Cutstr=Left(Trim(Str),X)&"..."
Loop
End If
End Function
end class
%>
|
|