note 93936 deleted from function.preg-match-all by danbrown

From: Date: Wed, 07 Oct 2009 16:53:21 +0000
Subject: note 93936 deleted from function.preg-match-all by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-161490@lists.php.net to get a copy of this message
Note Submitter: Jason ---- "Example #3 Using named subpattern" above does not work, at least in PHP 5. Named tags should contain a capital P after the question mark and before the less than sign. This: ?<name> Should look like this: ?P<name> So, the correct code for PHP5 for "Example #3 Using named subpattern", should look like this: <?php $str = <<<FOO a: 1 b: 2 c: 3 FOO; preg_match_all('/(?P<name>\w+): (?P<digit>\d+)/', $str, $matches); print_r($matches); ?> This will prevent an error similar to: "Warning: preg_match_all() [function.preg-match-all]: Compilation failed: unrecognized character after (?< at offset 3"

« previous php.notes (#161490) next »