[导入]ASP常用函数:TrimLR()

<%
'功能:返回去除前sStr、后sStr 或前后sStr 的字符串sString副本。(区分大小写)
'来源:http://jorkin.reallydo.com/article.asp?id=443

Public Function TrimLR(ByVal sString, ByVal sStr, ByVal sLeftOrRight)
    
Dim iStrLen : iStrLen = Len(sStr)
    
Select Case UCase(sLeftOrRight)
        
Case "L", "LEFT"
            
Do While Left(sString, iStrLen) = sStr
                sString = Mid(sString, iStrLen + 1)
            
Loop
        Case
"R", "RIGHT"
            
Do While Right(sString, iStrLen) = sStr
                sString = Mid(sString, 1, Len(sString) - iStrLen)
            
Loop
        Case Else
            
sString = TrimLR(sString, sStr, "L")
            
sString = TrimLR(sString, sStr, "R")
    
End Select
    
TrimLR = sString
End Function
%>


文章来源: http://Jorkin.Reallydo.Com/default.asp?id=444

你可能感兴趣的:(trim)