RE: [PHP] Pattern-Matching For Replacing Text

From: Date: Sun, 15 Oct 2000 21:36:17 +0000
Subject: RE: [PHP] Pattern-Matching For Replacing Text
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-20268@lists.php.net to get a copy of this message
Hi Jeff, regular expressions are a powerful tool in programming, but not easy to learn at first sight. If you're really interested in learning them I'd suggest you get the book 'Regular Expressions' by Jeffrey E.F. Friedl http://www.oreilly.com/catalog/regex/ aka 'The Owl Book'. You can also find some reference in the PHP manual: http://www.php.net/manual/ref.regex.php http://www.php.net/manual/ref.pcre.php and additionally here: http://www.perl.com/reference/query.cgi?regexp When you read this, then you'll understand why nobody can really give you any help here with your specific regex problem, without knowing the exact structure of the document. Anyways '%' is not a wildcard in a regex it is '.*'. Matthias aka Matthew -- $ [ Where is Jimmy Hoffa? [: missing `]´ > -----Original Message----- > From: Jeff Gannaway [mailto:webmaster@cactusgraphics.com] > Sent: Sunday, October 15, 2000 5:26 PM > To: php-general@lists.php.net > Subject: [PHP] Pattern-Matching For Replacing Text > > > 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 > _______________________________________________________ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#20268) next »