代码如下:
<%
FunctionSenFe_UbbCode(sContent)
DimTempReg
SetTempReg=NewRegExp
WithTempReg
.IgnoreCase=True
.Global=True
'自动识别网址
IfInStr(Lcase(sContent),"http://")>0Then
.Pattern="(^|[^<=""])(http:(////|////)(([/w/////+/-~`@:%])+/.)+([/w/////./=/?/+/-~`@/':!%#]|(&)|&)+)"
sContent=.Replace(sContent,"$1$2")
EndIf
'自动识别www等开头的网址
IfInStr(Lcase(sContent),"www.")>0orInStr(Lcase(sContent),"bbs.")>0Then
.Pattern="(^|[^/////w/=])((www|bbs)/.(/w)+/.([/w/////./=/?/+/-~`@/'!%#]|(&))+)"
sContent=.Replace(sContent,"$1$2")
EndIf
EndWith
SetTempReg=Nothing
SenFe_UbbCode=sContent
EndFunction
%>
- <script language="vbscript">
- Function SenFe_UbbCode(sContent)
- Dim TempReg
- Set TempReg = New RegExp
- With TempReg
- .IgnoreCase = True
- .Global = True
- '自动识别网址
- If InStr(Lcase(sContent),"http://")>0 Then
- .Pattern = "(^|[^<=""])(http:(////|////)(([/w/////+/-~`@:%])+/.)+([/w/////./=/?/+/-~`@/':!%#]|(&)|&)+)"
- sContent = .Replace(sContent,"$1<a href=""$2"" target=""_blank"">$2</a>")
- End If
- '自动识别www等开头的网址
- If InStr(Lcase(sContent),"www.")>0 or InStr(Lcase(sContent),"bbs.")>0 Then
- .Pattern = "(^|[^/////w/=])((www|bbs)/.(/w)+/.([/w/////./=/?/+/-~`@/'!%#]|(&))+)"
- sContent = .Replace(sContent,"$1<a href=""http://$2"" target=""_blank"">$2</a>")
- End If
- End With
- Set TempReg = Nothing
- SenFe_UbbCode = sContent
- End Function
- </script>
- <textarea name="scode" cols="50" rows="20"></textarea>
- <input type="button" value="替换" onclick="vbscript:document.getElementById('scode').value=SenFe_UbbCode(document.getElementById('scode').value)" />
新闻热点
疑难解答