note 69783 added to function.preg-match

From: Date: Wed, 20 Sep 2006 21:37:12 +0000
Subject: note 69783 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-117361@lists.php.net to get a copy of this message
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); ---- Server IP: 66.207.199.35 Probable Submitter: 66.212.234.114 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match.php Edit -- https://master.php.net/note/edit/69783 Del: integrated -- https://master.php.net/note/delete/69783/integrated Del: useless -- https://master.php.net/note/delete/69783/useless Del: bad code -- https://master.php.net/note/delete/69783/bad+code Del: spam -- https://master.php.net/note/delete/69783/spam Del: non-english -- https://master.php.net/note/delete/69783/non-english Del: in docs -- https://master.php.net/note/delete/69783/in+docs Del: other reasons-- https://master.php.net/note/delete/69783 Reject -- https://master.php.net/note/reject/69783 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117361) next »