note 14487 added to function.ereg-replace.php

From: Date: Thu, 02 Aug 2001 08:10:51 +0000
Subject: note 14487 added to function.ereg-replace.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-16199@lists.php.net to get a copy of this message
Dilemma: Encoding and Decoding text to URL and mail hyperlinks. I found lots of different ways to encode a hyperlink from text, but not one example of reversing the process, so... // Replace tekstlink with HyperLink $Text = ereg_replace('www+(\.[[:alnum:]~_-]+)+([/\.][[:alnum:]?&=~_-]+)*/*', '<A HREF="http://\\0" TARGET="_blank">\\0</A>', $Text); // Replace mailtext with HyperLink $Text = ereg_replace('[A-Za-z0-9]([A-Za-z0-9._]*[A-Za-z0-9]|())@[A-Za-z0-9]([A-Za-z0-9.\-]*[A-Za-z0-9]|())\.[A-Za-z]+', '<A HREF="mailto:\\0">\\0</A>', $Text); // Remove hyperlink $Text = ereg_replace('<A HREF="http://www+(\.[[:alnum:]~_-]+)+([/\.][[:alnum:]?&=~_-]+)*/*" TARGET="_blank">|</A>', '', $Text); // Remove maillink $Text = ereg_replace('<A HREF="mailto:+[A-Za-z0-9]([A-Za-z0-9._]*[A-Za-z0-9]|())@[A-Za-z0-9]([A-Za-z0-9.\-]*[A-Za-z0-9]|())\.[A-Za-z]+">|</A>', '', $Text); http://www.php.net/manual/en/function.ereg-replace.php

« previous php.notes (#16199) next »