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]

  Balsuoti

Leave a Reply

 

You need to log in to vote

The blog owner requires users to be logged in to be able to vote for this post.

Alternatively, if you do not have an account yet you can create one here.

Powered by Vote It Up

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!

Visit our friends!

A few highly recommended friends...