转换字符串带有

2018-09-06 13:11

阅读:737

  Code Title: Auto-linking
Description: How would you like to have every instance of an
address that follows it? Well, here is a killer little function that will take every one of those that it
finds in a string and sets up the hyperlink for you! Cool, eh?
Copy and paste this snippet as-is into your editor:

-------------------------------------------------------------------------
<%
Function LinkURLs(strInput)
iCurrentLocation = 1
Do While InStr(iCurrentLocation, strInput,
iLinkStart = InStr(iCurrentLocation, strInput,
iLinkEnd = InStr(iLinkStart, strInput, , 1)
If iLinkEnd = 0 Then iLinkEnd = Len(strInput) + 1
Select Case Mid(strInput, iLinkEnd - 1, 1)
Case ., !, ?
iLinkEnd = iLinkEnd - 1
End Select
strOutput = strOutput Mid(strInput, iCurrentLocation, iLinkStart - iCurrentLocation)
strLinkText = Mid(strInput, iLinkStart, iLinkEnd - iLinkStart)

iCurrentLocation = iLinkEnd
Loop
strOutput = strOutput Mid(strInput, iCurrentLocation)
LinkURLs = strOutput
End Function
strUnlinked =
strUnlinked = strUnlinked

Here is the before text:
vbCrLf
Response.Write strUnlinked
vbCrLf vbCrLf

Here is the text after it gets automatically hyperlinked to itself:
vbCrLf
Response.Write LinkURLs(strUnlinked)
%>
-------------------------------------------------------------------------


评论


亲,登录后才可以留言!