I am not quite sure but this will do the trick:

$fixedfile="<img src=\"\"; width=1 height=2>";
$fixedfile=preg_replace("/src=[^>]*?>/","src=\"<!---image goes here--->\">",


exit ($fixedfile);

I have made some differences from what you were trying to do:
I used preg_replace, I added ">" to the replacement since without it you
would get:
<img src="<!---image goes here--->" which would be incorrect HTML (<img
src=""> would be correct).

A note From a PHP manual.:
preg_replace(), which uses a Perl-compatible regular expression syntax, is
often a faster alternative to ereg_replace().

"Kelly Meeks" <[EMAIL PROTECTED]> wrote in message
Hi folks,

I'm trying my hand at some pattern matching, and I have a question.

I need to take all the text between the title tags of a page, and replace
it.  This I can do, with the following:

$fixedfile=ereg_replace("<title>.*</title>","<title><? echo \$bstitle;
?></title>", $fixedfile);
works like a charm....

Now I want to delete everything in the src section of an image tag, so I'm
trying this:

$fixedfile=ereg_replace("src=\".*\">","src=\"<!---image goes here--->\"",

but this doesn't work.

What am I doing wrong?


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to