RE: [PHP-GENERAL] eregi question

From: Date: Mon, 26 Jun 2000 20:25:45 +0000
Subject: RE: [PHP-GENERAL] eregi question
Groups: php.general 
Request: Send a blank email to php-general+get-3191@lists.php.net to get a copy of this message
> -----Original Message----- > From: czelenak@nxco.com [mailto:czelenak@nxco.com] > Sent: Monday, June 26, 2000 3:56 PM > To: php-general@lists.php.net > Subject: [PHP-GENERAL] eregi question > > > Taking my first hectic foray into Regular Expression stuff... > > $message=eregi_replace("<center>([[:alnum:]|[:space:]|[:punct: > ]]*)</center>","<tag>\\1</tag>",$message); > > Using the PHP eregi functions, I've been trying to capture everything > between <center>and </center> - however, as you can probably see, this > doesn't quite work like it's supposed to. For instance: > > <center> Bob </center> <b> Alice </b> <center> Bob > </center> > > Actually ends up returning this: > > <tag> Bob </center> <b> Alice </b> <center> Bob </tag> > > Does anyone know how I can work around this problem? I've tried [...] Use the perl one if you can: $message = pregi_replace("|\<center\>(.+?)\</center\>|",'\\1',$message); Or, if you just want to capture that text, like you said: $msg_start = strpos($message, "<center>") + strlen("<center>"); $msg_end = strpos($message, "</center>",$msg_start); $text = substr($msg_start,$msg_end); -John

« previous php.general (#3191) next »