转换字符串带有http://的超级链接字符串为真正的超级链接(源码)

2016-01-29 17:19 49 1 收藏

转换字符串带有http://的超级链接字符串为真正的超级链接(源码),转换字符串带有http://的超级链接字符串为真正的超级链接(源码)

【 tulaoshi.com - ASP 】

  Code Title: Auto-linking
Description: How would you like to have every instance of an http:// auto-hyperlink itself to the URL
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, "http://", 1) < 0
iLinkStart = InStr(iCurrentLocation, strInput, "http://", 1)
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)
strOutput = strOutput & "<a href="""&strLinkText&""""&strLinkText&"</a"
iCurrentLocation = iLinkEnd
Loop
strOutput = strOutput & Mid(strInput, iCurrentLocation)
LinkURLs = strOutput
End Function
strUnlinked = "http://LINE9.com rules! <br" & vbCrLf
strUnlinked = strUnlinked & "http://pdxpc.com sells great computers!<br" & vbCrLf

' Here is the before text:
Response.Write "<bOriginal Text:</b<br" & vbCrLf
Response.Write strUnlinked
Response.Write vbCrLf & "<br" & vbCrLf & vbCrLf

' Here is the text after it gets automatically hyperlinked to itself:
Response.Write "<bText After Linking:</b<br" & vbCrLf
Response.Write LinkURLs(strUnlinked)
%
-------------------------------------------------------------------------

 

来源:https://www.tulaoshi.com/n/20160129/1500987.html

延伸阅读
标签: 电脑入门
字符串格式定义 printf()函数 printf()函数是格式化输出函数, 一般用于向标准输出设备按规定格式输出信息。在编写程序时经常会用到此函数。printf()函数的调用格式为: printf("格式化字符串", 参量表); 其中格式化字符串包括两部分内容: 一部分是正常字符, 这些字符将按原样输出; 另一部分是格式化规定字符, 以"%"开始...
create or replace procedure ModifyLadingItemPack (   ASoditemguid varchar2,                  --合同电子仓单明细GUID   ALadingitemGUID varchar2,             &nb...
标签: autocad教程
超级链接简介     超级链接(Hyperlink)可以看作是一种文件的指针,它提供了相关联文件的路径,以指向在本地、网络驱动器或 Internet 上存储的文件,并可跳转到相应的文件;也可以在超级链接中指定跳转到文件中的一个命名位置,例如 Auto CAD 中的一个视图或字处理程序中的一个书签。     在...
在Excel 2000中是通过对工作表中的对象设定超链接来实现对Internet资源的访问的。实际上超级链接还能够跳转至硬盘,公司的内部网或诸如其上的全球广域网的某页。例如,可创建超级链接,从 word 文件跳转到提供详细内容的 Microsoft Excel 中的图表。超级链接由“热”映射或蓝色的带有下划线的显示文本表示。单击它们,即可跳转至其他...
Delphi中的字符串 ——摘自网络 一:各种字符串  字符串是Object Pascal所有数据类型中最有用的类型。许多函数以字符串为传递参数。由于在Delphi中字符串的定义和使用有各种方式,包括Pascal中典型的字符串(String),Delphi支持的长字符串(ANSIString),类似于C语言的字符数组(Array of Char),指向字符的...

经验教程

26

收藏

62
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部