1 (edited by Kolya 2007-01-27 05:05:26)

Topic: custom.php

This finds links marked with BBCode:

    // This finds http URLs in the form [url]http://www.google.com/page[/url]
    //$string = ereg_replace("\[url\](http:[^>\r\n]+)\[/url\]","${lt}a href=${q}\\1${q}${gt}\\1${lt}/a${gt}",$string);

The next one is better (imo) as it finds plain text Links. But it's either this or the BBCode one above.

    //This finds a plain text-url (http://www.google.com or www.google.com) and creates a link from it 
 
//"www."
   $pattern_preg1 = '#(^|\s)(www|WWW)\.([^\s<>\.]+)\.([^\s\n<>]+)#sm';
   $replace_preg1 = '\\1${lt}a href=${q}http://\\2.\\3.\\4${q} target=${q}_blank${q} class=${q}link${q}${gt}\\2.\\3.\\4${lt}/a${gt}';

//"http://"
   $pattern_preg2 = "#(^|[^\"=\]]{1})(http|HTTP|ftp)(s|S)?://([^\s<>\.]+)\.([^\s<>]+)#sm";
   $replace_preg2 = "\\1${lt}a href=${q}\\2\\3://\\4.\\5${q} target=${q}_blank${q} class=${q}link${q}${gt}\\2\\3://\\4.\\5${lt}/a${gt}";
  
   $string = preg_replace($pattern_preg1, $replace_preg1, $string);
   $string = preg_replace($pattern_preg2, $replace_preg2, $string);

Basic BulletinBoardCode:

 // This finds [b]BOLD TEXT[/b] [i]ITALIC TEXT[/i] [u]UNDERLINED TEXT[/u]
    $string = preg_replace("/\[(\/?)([biuq])\]/i", "${lt}$1$2${gt}", $string);