note 87152 added to function.preg-match

From: Date: Fri, 21 Nov 2008 17:35:21 +0000
Subject: note 87152 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-146799@lists.php.net to get a copy of this message
When I was using the above example's syntax for named capturing groups, it worked fine on my development server (PHP 5.2.6), but then gave me a regex error on the live server (PHP 5.0.4). By adding a 'P' in front of the parameter name, it seems to have resolved the issue (this is in accordance w/ the PCRE implementation). To use the above example, here's the original: <?php preg_match('/(?<name>\w+): (?<digit>\d+)/', $str, $matches); ?> And here's the fix: <?php preg_match('/(?P<name>\w+): (?P<digit>\d+)/', $str, $matches); ?> ---- Server IP: 64.71.164.2 Probable Submitter: 216.41.106.26 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match.php Edit -- https://master.php.net/note/edit/87152 Del: integrated -- https://master.php.net/note/delete/87152/integrated Del: useless -- https://master.php.net/note/delete/87152/useless Del: bad code -- https://master.php.net/note/delete/87152/bad+code Del: spam -- https://master.php.net/note/delete/87152/spam Del: non-english -- https://master.php.net/note/delete/87152/non-english Del: in docs -- https://master.php.net/note/delete/87152/in+docs Del: other reasons-- https://master.php.net/note/delete/87152 Reject -- https://master.php.net/note/reject/87152 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#146799) next »