D
dotNet
Hi!
I have this code, to replace www/http/mailto/ftp-links to a real <a
href>-tag.
----
Dim mDelimit As String = Chr(0)
oRegEx = New
Regex("[^<a](\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+)",
RegexOptions.IgnoreCase)
content = oRegEx.Replace(content, "<a href=""mailto" & mDelimit &
":$1"">$1</a>")
oRegEx = New Regex("[^<a](http://|https://|ftp://|mailto:)(\S)(\S+)",
RegexOptions.IgnoreCase)
content = oRegEx.Replace(content, "<a href=""$1$2" & mDelimit &
"$3"">$2" & mDelimit & "$3</a>")
oRegEx = New Regex("[^<a](www\.(\S)(\S+))", RegexOptions.IgnoreCase)
content = oRegEx.Replace(content, "<a href=""http://$1"">$1</a>")
content = Replace(content, mDelimit, "")
----
But it doesnt work very well, any suggestions?
I also want to be able to write my url
description and parse that to an a-tag aswell.
I have this code:
----
oRegEx = New Regex("\(.*?)\[\/url\]")
content = oRegEx.Replace(content, "<a href=""$1""
target=""_blank"">$2</a>", RegexOptions.IgnoreCase)
----
The problem with the code above is that if I have code like this:
[url=http://test1.com]test1
test2
test3
the link test1 and test2 will be parsed ok, but the link test3 will stay
in plain text. I guess that is because we have a empty row above the text.
Thanks![/url]
I have this code, to replace www/http/mailto/ftp-links to a real <a
href>-tag.
----
Dim mDelimit As String = Chr(0)
oRegEx = New
Regex("[^<a](\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+)",
RegexOptions.IgnoreCase)
content = oRegEx.Replace(content, "<a href=""mailto" & mDelimit &
":$1"">$1</a>")
oRegEx = New Regex("[^<a](http://|https://|ftp://|mailto:)(\S)(\S+)",
RegexOptions.IgnoreCase)
content = oRegEx.Replace(content, "<a href=""$1$2" & mDelimit &
"$3"">$2" & mDelimit & "$3</a>")
oRegEx = New Regex("[^<a](www\.(\S)(\S+))", RegexOptions.IgnoreCase)
content = oRegEx.Replace(content, "<a href=""http://$1"">$1</a>")
content = Replace(content, mDelimit, "")
----
But it doesnt work very well, any suggestions?
I also want to be able to write my url
description and parse that to an a-tag aswell.
I have this code:
----
oRegEx = New Regex("\(.*?)\[\/url\]")
content = oRegEx.Replace(content, "<a href=""$1""
target=""_blank"">$2</a>", RegexOptions.IgnoreCase)
----
The problem with the code above is that if I have code like this:
[url=http://test1.com]test1
test2
test3
the link test1 and test2 will be parsed ok, but the link test3 will stay
in plain text. I guess that is because we have a empty row above the text.
Thanks![/url]