Pattern-Matching For Replacing Text
| From: | Jeff Gannaway | Date: | Sun, 15 Oct 2000 15:25:49 +0000 |
| Subject: | Pattern-Matching For Replacing Text | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-20260@lists.php.net to get a copy of this message | ||
I've gone throught the PHP docs and cannot figure out how to do this,
except I believe it will use the ereg-replace command....
I have one giant string, $read and I want to isolate one block of text out
of it.
Let's suppose $read = "Garbage Junk<P><B>Good Stuff</B><BR>Stuff
To
Keep<P>More Garbage And Junk";
Since $read is going to be slightly different each time, i won't know
exactly what the "garbage" and the "good stuff" will be each time.
The pattern to keep would be "<P><B>Good Stuff:%<P>"
My original try was to do it in 2 steps....
$cleaned = str_replace("%<P><B>Good Stuff:%", "<P><B>Good
Stuff:%", $read);
$cleaned = str_replace("<P><B>Good Stuff:%<P>%",
"<P><B>Good Stuff:%<P>",
$cleaned);
But that didn't work at all. How the heck do I strip away the junk????
Thanks,
Jeff
_______________________________________________________
Find the right art print for your home.
* Search by artist, color, art style and subject.
* Preview the art prints against your wall color.
PopStreet.com is your avenue to art.
http://www.popstreet.com
_______________________________________________________