LinkURLs - Auto Links with Regular Expressions

30.01.2004

Okuyucu : 3.958
Günlük Okuyucu : 2,5

Orginally written by Lewis Moten. I modified Regex and fixed some problems about it.

Kaynak Kodunu Download Edin (Download Source Code);

/opensource/source-code/auto-url-regex.txt

Kaynak Kod;

1 : <%
2 : '// Copyright (c) 2000, Lewis Moten (modified by Ferruh Mavituna). All rights reserved.
3 : Function LinkURLs(ByVal asContent)
4 :     Dim loRegExp    ' Regular Expression Object (Requires vbScript 5.0 and above)
5 :     
6 :     ' If no content was received, exit the function
7 :     If asContent = "" Then Exit Function
8 :     
9 :     Set loRegExp = New RegExp     
10 :     loRegExp.Global = True
11 :     loRegExp.IgnoreCase = True

13 :         '//-- by Ferruh Mavituna {http://ferruh.mavituna.com}
14 :             '1/29/2004
15 :             '"www" added
16 :             '"www." fixed
17 :             '"www" fixed etc.
18 :             loRegExp.Pattern = "((((ht|f)tps?://)|www\.)\S+[^\.*](\s)?)"

20 :             ' Link URLs
21 :             LinkURLs = loRegExp.Replace(asContent, "<a href=""$1"">$1</a>")
22 :         ' // --

24 :         ' Look for email addresses
25 :          loRegExp.Pattern = "(\S+@\S+.\.\S\S\S?)"

27 :     ' Link email addresses
28 :     LinkURLs = loRegExp.Replace(LinkURLs, "<a href=""mailto:$1"">$1</a>")
29 :
30 :         ' Release regular expression object
31 :     Set loRegExp = Nothing     
32 : End Function
33 : %>
Source Script is modified version of HiLiter
Ferruh Mavituna
© 2002-2007, Ferruh Mavituna

Sabit IP Adresi : 81.22.99.133, SSL Erişimi, Hakkında