NeWorld

Aktivuojam nuorodas tekste

by neworld on Bir.07, 2007, under php

Kartais mums reikia aktyvuoti nuorodas tekste. Tačiau, nemokant regular expresion, arba silpnai, gali būti sunku tai padaryti. Tenka naudotis svetimais scriptais. Tai pateiksiu savajį variantą:

[code lang="php"]function searchURL($text) {
$textt=preg_replace("/(http:\/\/)?(([\w]+\.)+)(([\w]{2})|com|net|info|biz|org)((\/)?([\w]+\/)*([\w]+(\.[\w]{2,4})?)?(\?[\w=&%\+]*)?(#[\w]*)?)?(\.|[\W]|\Z)/i
","$2$4$6$13",$text);
return $textt;
}[/code]


Comments are closed.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!