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

2016-01-29 17:19 54 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)
%
-------------------------------------------------------------------------

 

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

延伸阅读
Delphi中的字符串 ——摘自网络 一:各种字符串  字符串是Object Pascal所有数据类型中最有用的类型。许多函数以字符串为传递参数。由于在Delphi中字符串的定义和使用有各种方式,包括Pascal中典型的字符串(String),Delphi支持的长字符串(ANSIString),类似于C语言的字符数组(Array of Char),指向字符的...
在许多程序的关于对话框中,我们常可以看到超级链接式的标签,只须轻轻一点,就能立即启动电子邮件程序给作者写信,或者启动浏览器观看某主页,或者远程登录,或者自动链入新闻组 如果你苦于找不到实现这些功能的Delphi控件,又无法在帮助文件中找到相关主题,那不妨参照下文,亲手一试! 别看上述的超级链接功能繁多,其实用一条...
标签: 办公软件
Word 2000有一些堪称智能的本领,比如你在文档中键入了一个网址或E-mail地址后,Word会自动将其转换为一个超级链接域,这样单击该超级链接即可直接跳至某个项目。这虽然大大方便了有需求的用户,但对不需要该功能的用户,却是一件烦心的事情。 在键入而且Word将Internet和网络路径自动转换为超级链接域后,立即按下BackSpace键或Ctrl+Z组...
标签: MySQL mysql数据库
  对于针对字符串位置的操作,第一个位置被标记为1。 ASCII(str) 返回字符串 str 的最左面字符的ASCII代码值。 如果 str 是空字符串,返回 0 。如果 str 是 NULL ,返回 NULL 。 mysql select ASCII('2'); - 50mysql select ASCII(2); - 50mysql select ASCII('dx'); - 100 也可参见ORD()函...
答:import java.util.*; class test { public static void main(String[] args) { String str1="001,002,003,004,006",str2 = "001,002,005"; String str=""; TreeSet ts = new TreeSet(); StringTokenizer st = new StringTokenizer(str1,","); while (st.hasMoreTokens()) { ts.add(st.nextToken()); } st = new StringToken...

经验教程

780

收藏

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