'본문에 웹사이트 주소가 있으면 자동으로 <a>태그를 생성해주는 함수.
Function replaceLink(str)
Dim patrn, regEx, match, matches, RetStr, regEx2, strEx
patrn = "http:\/\/[0-9a-zA-Z./~_-]+( ?|$)"
SET regEx = New RegExp ' 정규식을 만듭니다.
regEx.Pattern = patrn ' 패턴을 설정합니다.
regEx.IgnoreCase = True ' 대/소문자를 구분하지 않도록 합니다.
regEx.Global = True ' 전체 문자열을 검색하도록 설정합니다.
SET Matches = regEx.Execute(str)
SET regEx2 = New RegExp ' 정규식을 만듭니다.
regEx2.IgnoreCase = True ' 대/소문자를 구분하지 않도록 합니다.
regEx2.Global = True ' 전체 문자열을 검색하도록 설정합니다.
For Each Match in Matches ' Matches 컬렉션을 반복합니다.
regEx2.Pattern = Match.Value ' 패턴을 설정합니다.
strEx = Match.Value
str = regEx2.Replace(str, "<a href='" & strEx & "' target='_blank'>" & strEx & "</a>")
Next
replaceLink = str
End Function

글
댓글을 달아 주세요
댓글 RSS 주소 : http://haroc.haroc.net/tc/rss/comment/68