From:             [EMAIL PROTECTED]
Operating system: XP Pro
PHP version:      5CVS-2003-01-24 (dev)
PHP Bug Type:     Feature/Change Request
Bug description:  Link and Mailto parsing functions

First, this task can be accomplished with a regex, but it is only _so_
effective.

If there was some way to make functions that would take in a string, and
return a string that has all links, and all email addresses (2 seperate
functions, or one with a set of switches) properly formatted to work as
links.

The reason it is hard with regex, is becuase it is impossible to search
for a link when it can be formatted so many ways.



/********** simple **************/
$string = "Hey, check out http://www.spoonified.com, and email me at
[EMAIL PROTECTED]";

$linkified = hrefparse($string);

echo $linkified;
/*******************************/

returns this:

Hey, check out <a
href="http://www.spoonified.com";>http://www.spoonified.com</a>, and email
me at <a href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>



of course, the link, the main reason regex is bad, could have many things
in it, it could point to a file, have a query string in it, have no www,
have many PERIODS (multiple subdomains), be https://, and also not be
seperated from other text (such as "OMFGwww.spoonified.comRULES"), and the
list goes on.

Email addresses follow the same conditions i mentioned above (minus a few
of course, and plus a few also).

Maybe im just overlooking a complex enough regex to do this.

I DO know it can be done. Many IRC/Instant Message programs do a wonderful
job of it. They take a link, no matter what conditions, or an email
address, and will show an active link once sent. Obviously there is a
rexeg im too lame to understand, or a better way to accomplish it.



(also, you 5.0.xCVS is still having an error on the php4apache2.dll
compile, just a sidenote, no comments needed, i think you guys are already
aware)


-- 
Edit bug report at http://bugs.php.net/?id=21869&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=21869&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=21869&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=21869&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=21869&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=21869&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=21869&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=21869&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=21869&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=21869&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=21869&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21869&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=21869&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=21869&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=21869&r=gnused

Reply via email to