ASP 자동링크 함수(Function)
문장안에 URL이나 이메일 주소등 링크를 걸수 있는 문자열이 포함되어 있으면 자동으로 링크를 걸어주는 함수입니다
함수 위에있는 몇가지 ASP문은 잘되나 제가 테스트 해 본 것입니다. 잘되네요^^
======================================================================================================== <% dim content content = "검색엔진: " content = content & "네이버(http://www.naver.com)<br>" content = content & "아니면 다음(http://www.daum.net)<br>" content = content & "아니면 구글(http://www.google.co.kr)<br>" content = content & "아니면 야후(http://www.yahoo.co.kr)<br>"
content = AutoLink(content)
response.write content
function AutoLink (content)
dim link Set link = New RegExp
' First Pass for http link.Pattern = "(\w+):\/\/([^/:]+)(:\d*\b)?([^# \n<]*).*\n" link.Pattern = "([0-9a-zA-Z./@:~?&=_-]+)" link.Pattern = "http://([0-9a-zA-Z./@:~?&=_-]+)" link.Global = True link.IgnoreCase = True
' ASP seems to be not supporting .MultiLine method. 'link.MultiLine = True
content = link.Replace(content,"<a target=_blank href='http://$1'>http://$1</a>")
' 메일주소 자동링크 link.Pattern = "([_0-9a-zA-Z-]+(\.[_0-9a-zA-Z-]+)*)@([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)" AutoLink = link.Replace(content,"<a href='mailto:$1@$3'>$1@$3</a>")
end function %> ======================================================================================================== | |
|
|