ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 7th, 2003, 10:33 AM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 6
VB.Net Regular Expression

I'm working on a function that will take a block of text and convert any urls into hyperlinks. I confess to not knowing much at all about regular expressions. At any rate, what I have so far is working (). Unfortunately, it's working for everything. Anything you pass to it will become a URL, even text. How can I write this expression better?


Code:
Imports System.Text.RegularExpressions
Imports System.Uri

Function MakeLink(ByVal sURL)

Dim reString As String = "(?<url>[(http|ftp|https):\/\/]?[\w]+(.[\w]+)([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?)"
sOutput = Regex.Replace(sURL, reString, "<a href=""${url}"" target=""_blank"">${url}</a>", RegexOptions.IgnoreCase)

MakeLink = sOutput
End Function

Reply With Quote
  #2  
Old July 8th, 2003, 03:32 PM
EiSa EiSa is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Norway
Posts: 184 EiSa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 22 m 24 sec
Reputation Power: 6
Not good with regular expressions at all, but my luck is that there are scripts allready made:

http://www.4guysfromrolla.com/webte...t110900-1.shtml


And here you will find all kind of regular expressions:
http://regxlib.com/

Reply With Quote
  #3  
Old July 9th, 2003, 03:08 PM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 6
Thank you very much, EiSa! A little tweaking and this worked out perfectly for me...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > VB.Net Regular Expression


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway