ereg_replace question
| From: | The Master | Date: | Thu, 12 Oct 2000 03:56:56 +0000 |
| Subject: | ereg_replace question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-19744@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???
I'm running PHP 4.0b3 on Red Hat 6.1.
---------------------------------------------
The Master (Keith Schmit) master@thehaus.net
The Haus: http://www.thehaus.net/
Personal WWW: http://www.thehaus.net/~master/
---------------------------------------------
Cry HAVOC, and let slip the dogs of War.
--- Shakespeare, Julius Caesar