RE: [PHP] ereg_replace()

From: Date: Thu, 07 Sep 2000 02:34:20 +0000
Subject: RE: [PHP] ereg_replace()
Groups: php.general 
Request: Send a blank email to php-general+get-15649@lists.php.net to get a copy of this message
It's not a bug, it's the way you are using ereg_replace. The second argument is the replacement text (or reg exp). So in your case, the filter function is first called with arguments \1 and \2 (the first \ will be an escape character). To do what you want to do, you will have to assign the matched text to variables and then call filter, ie something like $templateLine = eregi_replace( $matchRegex, "\\1:\\2", $templateLine ); list($phase, $flag) = split (":", $templateLine); filter("phase", "$flag" ); > -----Original Message----- > From: Drew P. Vogel [mailto:dvogel@intercarve.net] > Sent: Thursday, 7 September 2000 12:40 > To: php-general@lists.php.net > Subject: [PHP] ereg_replace() > > > Hi. I am having a problem using a function as the second argument to > ereg_replace(). > > This is an excerpt from my code. Within the filer() function, the > paramaters act differently in different functions. > > BEGIN EXCERPT > > $matchRegex = "\[(.) (.)+ \]"; > while ( eregi( $matchRegex, $templateLine ) ) { > $templateLine = eregi_replace( $matchRegex, filter( > "\\2", "\\1" ), $templateLine ); > } > > function filter ( $phrase, $flags ) { > > END EXCERPT > > 'echo $flags;' outputs "\1", where 'return $flags;' returns > "L" (it is > supposed to return "L"). Is this a bug in php? Am I > misunderstanding the > use of \\n? > > --Drew Vogel > > > -- > 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 (#15649) next »