Function toLink(text)
Set regExp = New regexp
regExp.Global = true
regExp.IgnoreCase = true
text = html_entity_decode(text)
text = " ".text
text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'<a href="\\1">\\1</a>', text);
text = eregi_replace('(((f|ht){1}tps://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
'<a href="\\1">\\1</a>', text);
text = eregi_replace('([[:space:]()[{}])([url]www.[-a-zA-Z0-9@:%_\+.~#?&//=]+[/url])',
'\\1<a href="http://\\2">\\2</a>', text);
text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})',
'<a href="mailto:\\1">\\1</a>', text);
Set RegExp = Nothing
makeTags = text
End Function
Vad skall din metod ha för namn? makeTags eller toLink?
något i stil med:
Function toLink(text)
Dim myRegExp
text = Server.HTMLEncode(text)
Set myRegExp = New RegExp
myRegExp.IgnoreCase = True
myRegExp.Global = True
'URL Replace
myRegExp.Pattern = "(\b(f|ht)tps?://[-a-zA-Z0-9@:%_\+.~#?&//=]+\b)"
text = myRegExp.Replace(text, "<a href=""$1"">$1</a>")
'Email Replace
myRegExp.Pattern = "(\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}\b)"
text = myRegExp.Replace(text, "<a href=""mailto:$1"">$1</a>")
Set RegExp = Nothing
toLink = text
End Function
Borde vara det du är ute efter, e-post och url:er (http,ftp,ftps,https)