note 8979 added to ereg_replace

From: Date: Tue, 10 Oct 2000 03:22:39 +0000
Subject: note 8979 added to ereg_replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-6284@lists.php.net to get a copy of this message
Okay-here's a puzzle-I want to be able to do "custom tag replacement", which would take text like the following: <cmt The Master>This is a comment</cmt> and return <i>The Master comments: This is a comment</i> I thought this would do it: ereg_replace("(<cmt (.*)>(.*)</cmt>)","<i>\\2 comments: \\3</i>",$string) but it doesn't. It also COMPLETELY fails on text that contains <b>...</b> within the \\3 section, ie: <cmt The Master>This is <b>a</b> comment</cmt> This blows up with the following results: <i>The Master>This is <b>a</b comments: comment</i> I'd really prefer this format for the tags anyway but couldn't figure it out (I suck at regexes, yeah yeah :-) <cmt "The Master">some text</cmt> Any ideas/help/enlightenment??? http://www.php.net/manual/function.ereg-replace.php

« previous php.notes (#6284) next »