|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|
#2
|
|||
|
|||
|
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/ |
|
#3
|
|||
|
|||
|
Thank you very much, EiSa! A little tweaking and this worked out perfectly for me...
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > VB.Net Regular Expression |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|