ASP為字符串中的網(wǎng)址自動加上鏈接
更新時間:2008年06月25日 17:12:44 作者:
asp下用正則實現(xiàn)字符串中的網(wǎng)址加鏈接的代碼
<%
'字段內(nèi)網(wǎng)址加上聯(lián)接。
Function ToLink(Str)
Dim RE '正則表達(dá)式對象 Dim strContent
If IsNull(Str) Then Str = ""
Set RE = New RegExp '創(chuàng)建正 則表達(dá)式對象
With RE
.Global = True '搜索應(yīng)用于整個字符串
.IgnoreCase = True '搜索不區(qū)分大小寫的
strContent = Str
'***************************************************************
'郵件地址鏈接自動設(shè)置
'***************************************************************
.Pattern = "([\w]*)@([\w\.]*)"
strContent = .Replace(strContent, "<A Href='mailto:$1@$2'>$1@$2</A> ")
'***************************************************************
'鏈接自動設(shè)置
'***************************************************************
'======根據(jù)要求再添加協(xié)議名稱=======
Dim D(3), I
D(0) = "http"
D(1) = "ftp"
D(2) = "news"
D(3) = "mms"
'===================================
For I = 0 To UBound(D)
.Pattern = D(I) + ":\/\/([\w\.]*)"
strContent = .Replace(strContent, "<A Href='" + D(I) + "://$1' target=_blank>" + D(I) + "://$1</A> ")
Next
'***************************************************************
End With
Set RE = Nothing
ToLink = strContent
End Function
%>
'字段內(nèi)網(wǎng)址加上聯(lián)接。
Function ToLink(Str)
Dim RE '正則表達(dá)式對象 Dim strContent
If IsNull(Str) Then Str = ""
Set RE = New RegExp '創(chuàng)建正 則表達(dá)式對象
With RE
.Global = True '搜索應(yīng)用于整個字符串
.IgnoreCase = True '搜索不區(qū)分大小寫的
strContent = Str
'***************************************************************
'郵件地址鏈接自動設(shè)置
'***************************************************************
.Pattern = "([\w]*)@([\w\.]*)"
strContent = .Replace(strContent, "<A Href='mailto:$1@$2'>$1@$2</A> ")
'***************************************************************
'鏈接自動設(shè)置
'***************************************************************
'======根據(jù)要求再添加協(xié)議名稱=======
Dim D(3), I
D(0) = "http"
D(1) = "ftp"
D(2) = "news"
D(3) = "mms"
'===================================
For I = 0 To UBound(D)
.Pattern = D(I) + ":\/\/([\w\.]*)"
strContent = .Replace(strContent, "<A Href='" + D(I) + "://$1' target=_blank>" + D(I) + "://$1</A> ")
Next
'***************************************************************
End With
Set RE = Nothing
ToLink = strContent
End Function
%>
相關(guān)文章
asp下sql和access數(shù)據(jù)庫隨機(jī)取10條記錄的代碼newid()
利于搜索從表中隨機(jī)取幾條不重復(fù)記錄,一般都是10條,我就用了40條,大約的代碼就是下面的了2007-12-12rs.open sql,conn,1,1與rs.open sql,conn,1.3還有rs.open sql,conn,
Rs.Open語法如下:rs.Open Source,ActiveConnection,CursorType,LockType Source為sql語句,ActiveConnection為數(shù)據(jù)庫連接,CursorType是游標(biāo),LockType是數(shù)據(jù)鎖定類型.2011-01-01使用ASP在IIS創(chuàng)建WEB站點的函數(shù)
使用ASP在IIS創(chuàng)建WEB站點的函數(shù)...2007-01-01如何在 Access 2003 和 Access 2002 中創(chuàng)建 DSN 的連接到 SQLServer 對鏈接表
如何在 Access 2003 和 Access 2002 中創(chuàng)建 DSN 的連接到 SQLServer 對鏈接表...2006-10-10asp中用數(shù)據(jù)庫生成不重復(fù)的流水號
asp中用數(shù)據(jù)庫生成不重復(fù)的流水號的實現(xiàn)代碼,需要的朋友可以參考下實現(xiàn)原理其它程序一樣。2006-09-09