ID: 21869 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Duplicate Bug Type: Feature/Change Request Operating System: XP Pro PHP Version: 5CVS-2003-01-24 (dev) New Comment:
Dup of #6893. Previous Comments: ------------------------------------------------------------------------ [2003-01-24 16:13:37] [EMAIL PROTECTED] THIS PAGE DOES IT! (NOT THE EMAIL THOUGH) (but it is a non full proof regex?) Still, if it is a GOOD regex, that almost never messes up, a function would be ... easier :D ------------------------------------------------------------------------ [2003-01-24 16:11:32] [EMAIL PROTECTED] 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 this bug report at http://bugs.php.net/?id=21869&edit=1