note 69783 deleted from function.preg-match by felipe

From: Date: Mon, 10 Dec 2007 01:43:56 +0000
Subject: note 69783 deleted from function.preg-match by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133077@lists.php.net to get a copy of this message
Note Submitter: preg regexp ---- If you want to have perl equivalent regexp match: $`, $& and $' before the match, the match itself, after the match Here's one way to do it: echo preg_match("/(.*?)(and)(.*)/", "this and that",$matches); print_r($matches); $` = ${1}; $& = ${2}; $' = ${3}; Notice (.*) else the end won't match. Note that if you only need $&, simply use ${0}. Here's another way, which is a bit simpler to remember: echo preg_match("/^(.*?)(and)(.*?)$/", "this and that",$matches); print_r($matches);

« previous php.notes (#133077) next »