Re: preg_replace help needed...
| From: | Marek Kilimajer | Date: | Tue, 08 Apr 2003 17:18:03 +0000 |
| Subject: | Re: preg_replace help needed... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142920@lists.php.net to get a copy of this message | ||
preg_replace('|{h1:([^}]+)}([^{]+){/h1}|', '<a href="$1" target="_blank">$2</a>',$string);
untested
speedfreak@chello.be wrote:
For a simple CMS (PHP of course) I'm trying to preg_replace user input of form $str = "Here is a {hl:http://www.test.com/1}link{/hl}. And this is {hl:http://www.test.com/2}another{/hl}."; into 'Here is a <a href="http://www.test.com/1" target="_blank">link</a>. And this is <a href="http://www.test.com/1" target="_blank">another</a>.' I have been trying to get my head around (Perl-Compatible) regular expressions, but I've got a longway to go and I need this functionality asap... Please cc me (digest subscriber), speedfreak