---
title: "RegExp - http och www till <a href\"\"> ?"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/65499-regexp-http-och-www-till-a-href"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "CatZ"
published: "2003-01-20T09:25:56.000Z"
updated: "2003-01-20T09:37:11.000Z"
replies: 2
views: 229
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/65499-regexp-http-och-www-till-a-href"
---

# RegExp - http och www till <a href""> ?

## #1 — CatZ, 2003-01-20T09:25Z

Antar att man ska göra det när man hämtar informationen från databasen för att hålla nere databasens storlek. Men frågan är... HUR gör man ?

Jag har 0 koll på regexp....

Permalänk: https://www.webforum.nu/p/65499

## #2 — andreas_lindh, 2003-01-20T09:32Z

Jag har den här funktionen som jag hittade här på wf.

```
Function GetUrl(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 = "([url]http://[/url]|[url]https://[/url]|[url]ftp://[/url]|mailto:)(\S)(\S+)"
strText = re.Replace(strText, "<a href=""$1$2" & mDelimit & "$3"" target=""_blank"">$2" & mDelimit & "$3</a>")

re.Pattern = "(www\.(\S)(\S+))"
strText = re.Replace(strText, "<a href=""http://$1"" target=""_blank"">$1</a>")
strText = Replace(strText, mDelimit, "")

GetUrl=strText

End Function
```

Permalänk: https://www.webforum.nu/p/919744

## #3 — CatZ, 2003-01-20T09:37Z

Tack så mycket :D Nu ska jag sätta mig och försöka förstå hur detta fungerar! ;)

Permalänk: https://www.webforum.nu/p/919749

---

Tråden på webben: https://www.webforum.nu/amne/asp/65499-regexp-http-och-www-till-a-href
