|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-03-13 21:01 UTC] cloudyovercuba at gmail dot com
Description: ------------ In the documentation for preg_match_all at http://www.php.net/preg_match_all , example #3 shows that a example regex for named subpatterns is this: /(?<name>\w+): (?<digit>\d+)/ This does not work, and returns an error. The proper regex would be this: /(?P<name>\w+): (?P<digit>\d+)/ PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 18:00:02 2026 UTC |
The example is correct, it just requires PCRE 7.0, which is bundled with PHP5.2.2+. $ sapi/cli/php -r 'preg_match("/(?<name>\w+): (?<digit>\d+)/", "foo: 111", $m);print_r($m);' Array ( [0] => foo: 111 [name] => foo [1] => foo [digit] => 111 [2] => 111 )