-
FunctionAutoLinkURLs(strString)
-
Dimmatch,matches,offset,url,email,link,relnkAutoLinkURL
-
relnkAutoLinkURL="<ahref=""[[%URL%]]"">[[%URLText%]]</a>"
-
IfNotIsObject(regExp)ThenSetregExp=NewRegExp
-
regExp.Global=True
-
regExp.IgnoreCase=True
-
'LookforURLs
-
regExp.Pattern="(((ht|f)tps?://)|(www\.))([\w-]+\.)+[\w-:]+(/[\w-./?%#;&=]*)?"
-
Setmatches=regExp.Execute(strString)
-
offset=0
-
ForEachmatchinmatches
-
url=match
-
IfLeft(url,4)="www."Thenurl="http://"&url
-
link=Replace(Replace(relnkAutoLinkURL,"[[%URLText%]]",match),"[[%URL%]]",url)
-
strString=Mid(strString,1,match.FirstIndex+offset)&link&Mid(strString,match.FirstIndex+1+match.Length+offset,Len(strString))
-
offset=offset+Len(link)-Len(match)
-
Next
-
'Lookforemails
-
regExp.Pattern="[A-Za-z0-9_+-.']+@\w+([-.]\w+)*\.\w+([-.]\w+)*"
-
Setmatches=regExp.Execute(strString)
-
offset=0
-
ForEachmatchinmatches
-
email=match
-
link=Replace(Replace(relnkAutoLinkURL,"[[%URLText%]]",match),"[[%URL%]]","mailto:"&email)
-
strString=Mid(strString,1,match.FirstIndex+offset)&link&Mid(strString,match.FirstIndex+1+match.Length+offset,Len(strString))
-
offset=offset+Len(link)-Len(match)
-
Next
-
AutoLinkURLs=strString
-
EndFunction
如果您对该产品感兴趣,请填写办理(客服微信:xiaoxiongyidong)
发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。