现在的位置: 首页 > 综合 > 正文

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

2012年09月28日 ⁄ 综合 ⁄ 共 694字 ⁄ 字号 评论关闭

<%
'功能:在一个字符串前面补全另一字符串
'来源:http://jorkin.reallydo.com/article.asp?id=452

Public Function LFill(ByVal sString, ByVal sStr)
    
Dim i, iStrLen : iStrLen = Len(sStr&"")
    
For i = iStrLen To 1 Step -1
        
If Right(sStr, i ) = Left(sString, i ) Then Exit For
    Next
    
LFill = Left(sStr, iStrLen - i) & sString
End Function
%>

<%
'功能:在一个字符串后面补全另一字符串
'来源:http://jorkin.reallydo.com/article.asp?id=452

Public Function RFill(ByVal sString, ByVal sStr)
    
Dim i, iStrLen : iStrLen = Len(sStr&"")
    
For i = iStrLen To 1 Step -1
        
If Left(sStr, i) = Right(sString, i) Then Exit For
    Next
    
RFill = sString & Mid(sStr, i + 1)
End Function
%>

例如:
<%=RFill(LFill("www.reallydo.com/article.asp","http://"),"article.asp?id=452")%>

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

抱歉!评论已关闭.