ASP 删除字符串开始或/和末尾处指定字符(串)
发布时间:2016-08-05 14:35:05编辑:丝画阁阅读(627)
-
'删除字符串开始处指定字符(串)
-
Function TrimLeft(strIn, strTrim)
-
If IsNull(strIn) Or strIn="" Then
-
TrimLeft = ""
-
Exit Function
-
End If
-
If IsNull(strTrim) Or strTrim="" Then
-
TrimLeft = strIn
-
Exit Function
-
End If
-
While (Left(strIn, Len(strTrim)) = strTrim)
-
strIn = Mid(strIn, Len(strTrim) + 1)
-
Wend
-
TrimLeft = strIn
-
End Function
-
-
'删除字符串末尾处指定字符(串)
-
Function TrimRight(strIn, strTrim)
-
If IsNull(strIn) Or strIn="" Then
-
TrimRight = ""
-
Exit Function
-
End If
-
If IsNull(strTrim) Or strTrim="" Then
-
TrimRight = strIn
-
Exit Function
-
End If
-
While (Right(strIn, Len(strTrim)) = strTrim)
-
strIn = Left(strIn, Len(strIn) - Len(strTrim))
-
Wend
-
TrimRight = strIn
-
End Function
-
-
'删除字符串开始/末尾处指定字符(串)
-
Function TrimLeftRight(strIn, strTrim)
-
If IsNull(strIn) Or strIn="" Then
-
TrimLeftRight = ""
-
Exit Function
-
End If
-
If IsNull(strTrim) Or strTrim="" Then
-
TrimLeftRight = strIn
-
Exit Function
-
End If
-
strIn = TrimLeft(strIn, strTrim)
-
TrimLeftRight = TrimRight(strIn, strTrim)
-
End Function