0
自动保持URL我用下面的代码来自动创建我的琴弦链接。但我怎么转换像一个链接:点击带格式的URL标题
http://stackoverflow.com/questions/ask
到:
<a href="http://stackoverflow.com/questions/ask">stackoverflow.com</a>
因为它是现在,输出结果是:提前
<a href="http://stackoverflow.com/questions/ask">http://stackoverflow.com/questions/ask</a>
谢谢!
Function create_links(strText)
strText = " " & strText
strText = ereg_replace(strText, "(^|[\n ])([\w]+?://[^ ,""\s<]*)", "$1<a href=""$2"">$2</a>")
strText = ereg_replace(strText, "(^|[\n ])((www|ftp)\.[^ ,""\s<]*)", "$1<a href=""http://$2"">$2</a>")
strText = right(strText, len(strText)-1)
create_links = strText
end function
Function ereg_replace(strOriginalString, strPattern, strReplacement)
' Function replaces pattern with replacement
dim objRegExp : set objRegExp = new RegExp
objRegExp.Pattern = strPattern
objRegExp.IgnoreCase = True
objRegExp.Global = True
ereg_replace = objRegExp.replace(strOriginalString, strReplacement)
set objRegExp = nothing
end function
'objRegExp.replace( “> HTTP://”, “>”)'会摆脱'为http:// '在链接文字。添加'>'到REPLACE语句应确保href属性不受影响 – John 2014-12-01 23:31:02