字符截取函数-asp 字符截取程序
字符截取函数-asp教程 字符截取程序
Public Function CutStr(byVal val,byVal length,byVal endStr)
Dim l,t,c,i
If val = "" Or IsNull(val) Then
CutStr = ""
Exit Function
End If
If length = "" Or Int(length) <= 0 Or IsNumeric(length) = False Then
CutStr = val
Exit Function
End If
val = LoseHTML(val)
l = Len(val)
length = Int(length)
t = 0
For i = 1 To l
c = Ascw(Mid(val,i,1))
If c < 0 Or c > 255 Then t = t + 2 Else t = t + 1
IF t >= length Then
CutStr = Left(val,i) & endStr
Exit For
Else
CutStr = val
End If
Next
End Function
Public Function LoseHtml(ContentStr)
If ContentStr = "" Or IsNull(ContentStr) Or IsEmpty(ContentStr) Then
LoseHtml = ""
Else
Dim tempLoseStr,regEx
tempLoseStr = Cstr(ContentStr)
Set regEx = New RegExp
regEx.Pattern = "</*[^<>]*>"
regEx.IgnoreCase = True
regEx.Global = True
tempLoseStr = regEx.Replace(tempLoseStr,"")
LoseHtml = tempLoseStr
End if
End Function
补充:asp教程,高级应用