$line = htmlentities(stripslashes($line));
    $line = nl2br($line);
    $line = eregi_replace("\[(link|url)=(.*)\](.*)\[/(link|url)\]","<a
href=\"\\2\" target=\"_blank\">\\3</a>",$line);
    $line = eregi_replace("\[color=(.*)](.*)\[/color\]", "<font
color=\"\\1\">\\2</font>", $line);
    $line =
eregi_replace("\[(blockquote|indent)\](.*)\[/(blockquote|indent)\]",
"<blockquote>\\2</blockquote>", $line);
    $line = eregi_replace("\[(img|image)\](.*)\[/(img|image)\]","<img
src=\"\\2\">",$line);
    $line =
eregi_replace("\[(/?(b|hr|center|p|h1|h2|h3|h4|h5|h6|pre|u|i))\]","<\\1>",$l
ine);
    // Auto-linking code. Converts http, ftp, and www URL's, and email
address, into a hyperlink
    $line =
eregi_replace("([[:space:]])((f|ht)tp:\/\/[a-z0-9~#%@\&:=?\/\._-]+[a-z0-9~#%
@\&=?\/_-]+)", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $line);
//http
    $line =
eregi_replace("([[:space:]])(www\.[a-z0-9~#%@\&:=?\/\._-]+[a-z0-9~#%@\&=?\/_
-]+)", "\\1<a href=\"http://\\2\"; target=\"_blank\">\\2</a>", $line); //
www.
    $line =
eregi_replace("([[:space:]])([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}
)","\\1<a href=\"mailto:\\2\";>\\2</a>", $line); // mail
      $line =
eregi_replace("^((f|ht)tp:\/\/[a-z0-9~#%@\&:=?\/\._-]+[a-z0-9~#%@\&=?\/_-]+)
", "<a href=\"\\1\" target=\"_blank\">\\1</a>", $line); //http
    $line =
eregi_replace("^(www\.[a-z0-9~#%@\&:=?\/\._-]+[a-z0-9~#%@\&=?\/_-]+)", "<a
href=\"http://\\1\"; target=\"_blank\">\\1</a>", $line); // www.
    $line =
eregi_replace("^([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})","<a
href=\"mailto:\\1\";>\\1</a>", $line); // mail
      $line = eregi_replace("@","&#64;",$line);
       $line = str_replace("  ", "&nbsp;&nbsp;", $line);
       $line = str_replace("[indent]", "<blockquote>", $line);
       $line = str_replace("[/indent]", "</blockquote>", $line);
       $line = str_replace("(TM)", "<FONT SIZE=1><SUP>TM</SUP></FONT>",
$line);
       $line = str_replace("\t",
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $line);
       echo $line;
----- Original Message -----
From: "Marc Davenport" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 08, 2001 11:38 PM
Subject: [PHP] Regular expressions


> Hello all,
>    I've been trying to find a good regular expression pattern to find
> URLs.  I have found some that work fine when the protocol is included ie
> http://www.php.net . But I can not find one that will find www.php.net .
> Does anyone know where a good database of Regular expressions can be
> found? or have a regular expression that can do this?
>
> cheers,
> Marc Davenport
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to