自动识别HTML的标记 替换连接
自动识别HTML的标记 替换连接
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:

复制代码 代码如下:

<%

FunctionSenFe_UbbCode(sContent)

DimTempReg

SetTempReg=NewRegExp

WithTempReg

.IgnoreCase=True

.Global=True

'自动识别网址

IfInStr(Lcase(sContent),"http://")>0Then

.Pattern="(^|[^<=""])(http:(//|)(([w/+-~`@:%])+.)+([w/.=?+-~`@':!%#]|(&)|&)+)"

sContent=.Replace(sContent,"$1<ahref=""$2""target=""_blank"">$2</a>")

EndIf

'自动识别www等开头的网址

IfInStr(Lcase(sContent),"www.")>0orInStr(Lcase(sContent),"bbs.")>0Then

.Pattern="(^|[^/w=])((www|bbs).(w)+.([w/.=?+-~`@'!%#]|(&))+)"

sContent=.Replace(sContent,"$1<ahref=""http://$2""target=""_blank"">$2</a>")

EndIf

EndWith

SetTempReg=Nothing

SenFe_UbbCode=sContent

EndFunction

%>

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新正则表达式学习
热门正则表达式学习
编程开发子分类