note 14317 deleted from function.eregi-replace by jimw

From: Date: Fri, 02 Nov 2001 02:08:33 +0000
Subject: note 14317 deleted from function.eregi-replace by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-20246@lists.php.net to get a copy of this message
Hi, The idea: eregi_replace( "((http|https|mailto|ftp):(\/\/)?[^[:space:]<>]{1,})", "<a href='\\1'>\\1</a>",$url) is very smart, and short, but i've found one bug. It has errors while interpreting URLs in normal texts, because it includes in <a></a> chars placed right after parsed URL, for example: "This is our link: http://www.something.xx/didi.php. So please click it!" The result: This is our link: <a href='http://www.something.xx/didi.php.'>http://www.something.xx/didi.php.</a> So please click it! ##### HINT ##### In my experience, the best bugless idea is to use: eregi_replace("((ftp://)|(http://)|(www))(([a-z0-9.\-])*)(@)?(([a-z0-9\.])*)(([:/])?)((([a-z0-9]*)(@?)/*)+([.a-z]{2,4}){1})?((\??[a-z0-9\=]*)?)((\&[a-z0-9\=]*)?)(([\.a-z]){2,4})?", "<a href=\"\\0\">\\0</a>", $out); This second idea was posted here by someone else. And is placed above my note. Read it. It's very valuable (for me was). ;) Have a nice code. ;)

« previous php.notes (#20246) next »