sifixMedlem sedan maj 200373 inlägg Finns det nåt sätt att ta bort querystrings så att
http://www.ensida.se?id=345
blir
<a href="http://www.ensida.se?id=345">www.ensida.se</a>
när man kör denna?
Function convertLink(ByVal strText)
Dim mDelimit
Dim re
mDelimit = Chr(0)
Set re = New RegExp
re.Global = True
re.IgnoreCase = true
re.pattern = "\[url=([^]]+)](.+?)\[/url]"
strText = re.replace(strText, "<a href=""$1"">$2</a>")
re.Pattern = "(\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+)"
strText = re.Replace(strText, "<a href=""mailto" & mDelimit & ":$1"">$1</a>")
re.Pattern = "(^|\s)(http://|https://|ftp://|mailto:)(\S)(\S+)"
strText = re.Replace(strText, "$1<a href=""$2$3" & mDelimit & "$4"" target=""_blank"">$3" & mDelimit & "$4</a>")
re.Pattern = "(^|\s)(www\.(\S)(\S+))"
strText = re.Replace(strText, "$1<a href=""http://$2"" target=""_blank"">$2</a>")
strText = Replace(strText, mDelimit, "")
convertLink=strText
End Function
Ersätt:
re.Pattern = "(^|\s)(http://|https://|ftp://|mailto:)(\S)(\S+)"
strText = re.Replace(strText, "$1<a href=""$2$3" & mDelimit & "$4"" target=""_blank"">$3" & mDelimit & "$4</a>")
re.Pattern = "(^|\s)(www\.(\S)(\S+))"
strText = re.Replace(strText, "$1<a href=""http://$2"" target=""_blank"">$2</a>")
med:
re.Pattern = "\b(http://|https://|ftp://|mailto:)(\S+)(\?\S+)\b"
strText = re.Replace(strText, "<a href=""$1$2$3"" target=""_blank"">$1$2</a>")
re.Pattern = "\b(www\.[^\s\?]+)(\?\S+)?\b"
strText = re.Replace(strText, "<a href=""http://www.$1$2"" target=""_blank"">$1</a>")
sifixMedlem sedan maj 200373 inlägg Funkar med
www.ensida.se?id=345
men skriver man
http://www.ensida.se?id=345
så blir det så här
<a href="http://<a href="http://www.ensida.se?id=345" target="_blank">www.ensida.se</a>" target="_blank">http://<a href="http://www.ensida.se</a" target="_blank">www.ensida.se</a</a>>
re.Pattern = "(^|\s)(www\.[^\s\?]+)(\?[^\s]+)?(?=$|\W)"
strText = re.Replace(strText, "$1<a href=""http://www.$2$3"" target=""_blank"">$2</a>")
istället för:
re.Pattern = "\b(www\.[^\s\?]+)(\?\S+)?\b"
strText = re.Replace(strText, "<a href=""http://www.$1$2"" target=""_blank"">$1</a>")
sifixMedlem sedan maj 200373 inlägg Tackar, nu funkar det.
Så här blev det till slut.
Function convertLink(ByVal strText)
Dim mDelimit
Dim re
mDelimit = Chr(0)
Set re = New RegExp
re.Global = True
re.IgnoreCase = true
re.Pattern = "(\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+)"
strText = re.Replace(strText, "<a href=""mailto" & mDelimit & ":$1"">$1</a>")
re.Pattern = "\b(http://|https://|ftp://|mailto:)(\S+)(\?\S+)\b"
strText = re.Replace(strText, "<a href=""$1$2$3"" target=""_blank"">$2</a>")
re.Pattern = "(^|\s)(www\.[^\s\?]+)(\?[^\s]+)?(?=$|\W)"
strText = re.Replace(strText, "<a href=""http://$1$2$3"" target=""_blank"">$2</a>")
strText = Replace(strText, mDelimit, "")
convertLink=strText
End Function