note 15814 deleted from function.ereg by jimw

From: Date: Fri, 02 Nov 2001 01:30:47 +0000
Subject: note 15814 deleted from function.ereg by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-20164@lists.php.net to get a copy of this message
Pattern matching with dashes - the dash "-" must come FIRST in a pattern. This is NOT TRUE with preg. For example $in='abc-123'; echo ereg_replace('[a-z-]', '', $in); will return '-123', not '123'. Adding a slash in front of the 2nd "-", as echo ereg_replace('[a-z\-]','', $in); makes no difference. Using preg_replace would return '123'. Change ereg_replace to echo ereg_replace('[-a-z]', '', $in); and you'll get '123' back. This as of php 4.0.5. -Ben

« previous php.notes (#20164) next »