ereg_replace
| From: | olinux o | Date: | Fri, 29 Jun 2001 19:29:17 +0000 |
| Subject: | ereg_replace | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-9978@lists.php.net to get a copy of this message | ||
I have a large string and want to replace some
substrings in it.
This substrings are delimited by a pair of tags (all
substrings), say: <tag> and </tag>. i.e. There is the
<tag> tag at the beginning of the substring I want to
replace and a </tag> tag at the end. There are several
of this substrings along my large string.
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>.
How do I get the desired result??
Another way that would work for me is if i can return
an array of all of the matches
preg_match looks like it will do this [and then
matches can be referenced by using array[1], array[2]
etc. and array[0] holds ALL of the matches] however it
does not seem to be working...
TIA
olinux
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/