note 53749 added to function.preg-replace

From: Date: Sat, 11 Jun 2005 17:19:31 +0000
Subject: note 53749 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-90271@lists.php.net to get a copy of this message
I've just discovered something very annoying the hard way: (an hour of insanity-checking my code) When using preg_replace (or anyother preg_...function I assume), with numerical quantifiers such as {n,m}, it is imperative not(!) to have whitespace following the comma. Thus: NOT working example: $string = preg_replace('#([search parameters]{2, 2})#', 'replacement', $string); Working example: $string = preg_replace('#([search parameters]{2,2})#', 'replacement', $string); This may be common knowledge for some, but it illuded me - especially as I find it good readabillity practice, always to add a whitespace after a comma. Regards, Michael (DK). ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+53749 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53749&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53749&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53749&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53749&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53749&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+53749&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#90271) next »