Re: another REGEX question

From: Date: Thu, 02 Aug 2001 22:15:48 +0000
Subject: Re: another REGEX question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-61005@lists.php.net to get a copy of this message
Hi Julian, personally, I'd take out both tags, using something like: $str = preg_replace("/<\/?p.*?>/i", "", $str); Which gets rid of: <p> <p align="whatever"> </p> Or any case insensitive matches. That's probably just me though ;) James. "Julian Simpson" <frithj@home.com> wrote in message news:20010802214051.BGVV22490.femail29.sdc1.sfba.home.com@cr37888-a... > $str = eregi_replace('<p[^>]*>', ' ', $str); worked! > > thanx guys > > Julian > > >At 5:19 PM -0400 8/2/01, Jack Dempsey wrote: > >>Try > >>$str = preg_replace("<p.*?>", " ",$str); > >> > >>jack > > > > > >Or > > $str = eregi_replace('<p[^>]*>', ' ', $str); > > > >This matches <p (or <P), followed by any character string that > >DOESN'T include a >, then the trailing >. > > > >Preg functions are faster, though. And, if you're interested in > >little speed tweaks, use single quotes - ' - rather than double > >quotes - " - here. With double quotes, PHP searches the quoted string > >for variables or escape characters to replace. > > > > -steve > > > >> > >>-----Original Message----- > >>From: Julian Simpson [mailto:frithj@home.com] > >>Sent: Thursday, August 02, 2001 5:16 PM > >>To: php-general@lists.php.net > >>Subject: [PHP] another REGEX question > >> > >>I have a string can look like either of the following: > >><p>some stuff</p> > >><p align = "left">some stuff</p> > >> > >>I want to use eregi_replace to take out the first p tag whether it be > >><p> or <p align......> with a space > >> > >>I assumed that $str = eregi_replace ("<p.*>", " ",$str); > >>but it matches the entire string and thus turns the whole string into > >>one space. > >>aparently regex will match the biggest possible match rather than the > >>smallest > >>my question is how do i get it to match the smallest. > >> > >>thanx in advance.. > >> > >>Julian > >> > > > > > >-- > >+------ Factoid: Of the 100 largest economies in the world, 51 are ------+ > >| Steve Edberg University of California, Davis | > >| sbedberg@ucdavis.edu Computer Consultant | > >| http://aesric.ucdavis.edu/ > >http://pgfsun.ucdavis.edu/ | > >+--- corporations ------ http://www.ips-dc.org/reports/top200text.htm ---+ > > > > >

« previous php.general (#61005) next »