Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2001071

[PHP-DB] Re: ereg_replace From: Søren Nielsen (son <email protected>)
Date: 07/09/01

> >What I'm doing is using ereg_replace in this form:
> >$LargeString = ereg_replace("<tag>.*</tag>",
> >"replacement", "$LargeString");
> >but what I get is the string with the replacement in a
> >way I don't actually want. It replaces the part of the
> >string that begins with THE FIRST TAG <tag> and that
> >ends with THE LAST TAG </tag>.

Use preg_raplace and make it "ungreddy" using "?" :
$LargeString = preg_replace("|<tag>.*?</tag>|","replacement",
$LargeString);

Regards,
Soeren

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>