View Single Post
Sponsorlu Bağlantılar
Zoque.Forum
Advertisement
Old 07.02.2006   #7 (permalink)
MuratCorlu82
 
Üyelik Tarihi: 08.03.2004
Yer: İstanbul
Yaş: 26
Mesaj: 41
Re: Bir yazı içerisinde url ve mail adresi tanımlamak

ASP için örnek kod:
Kod:
function create_links(strText)
  strText = " " & strText
  strText = ereg_replace(strText, "(^|[\n ])([\w]+?://[^ ,""\s<]*)", "$1<a href=""$2"">$2</a>")
  strText = ereg_replace(strText, "(^|[\n ])((www|ftp)\.[^ ,""\s<]*)", "$1<a href=""http://$2"">$2</a>")
  strText = ereg_replace(strText, "(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)", "$1<a href=""mailto:$2@$3"">$2@$3</a>")
  strText = right(strText, len(strText)-1)
  create_links = strText
end function

function ereg_replace(strOriginalString, strPattern, strReplacement)
  ' Function replaces pattern with replacement
  dim objRegExp : set objRegExp = new RegExp
  objRegExp.Pattern = strPattern
  objRegExp.IgnoreCase = True
  objRegExp.Global = True
  ereg_replace = objRegExp.replace(strOriginalString, strReplacement)
  set objRegExp = nothing
end function
Kullanıımı: Mesela tablodaki içerik sütunu Icerik olsun.
Kod:
response.write create_links(ks("Icerik"))
MuratCorlu82 şu an çevrimdışı   Mesajdan alıntı yaparak yeni bir cevap ekleyin