• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
内蒙古峰回路转armyfeng
博客园    首页    新随笔    联系   管理    订阅  订阅

asp实现替换指定规则的字符串


<%@ Language=VBScript %>
<%
Dim srcPath,  dstPath        ' 以“|”分隔的字符串
Dim srcPaths, dstPaths        ' 分解后的数组

' 定义源字符串与目的字符串的对应关系,以“|”分隔
'
 /*****************只要修改这里*****************/
srcPath = "eastday/news|eastday/sports"
dstPath 
= "http://news.eastday.com|http://sports.eastday.com"
' /*****************只要修改这里*****************/


srcPaths 
= Split(srcPath, "|")
dstPaths 
= Split(dstPath, "|")

Function ReplaceURL(sURL)
    
Dim nIndex                ' 计数器
    
    
If ((UBound(srcPaths) - LBound(srcPaths)) = (UBound(dstPaths) - LBound(dstPaths))) Then
        
For nIndex = LBound(srcPaths) To UBound(srcPaths)
            
If (Left(sURL, Len(srcPaths(nIndex))) = srcPaths(nIndex)) Then
                sURL 
= Replace(sURL, srcPaths(nIndex), dstPaths(nIndex))
                
Exit For
            
End If
        
Next
    
End If
    ReplaceURL 
= sURL
End Function
%>
<html>
<head>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
</head>
<body>

<%=ReplaceURL("eastday/news/userobject1ai234.html")%>
<br>
<%=ReplaceURL("eastday/sports/userobject1ai567.html")%>
</body>
</html>
posted @ 2006-11-04 07:58  老冯  阅读(564)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3