note 55323 added to function.ereg

From: Date: Sat, 30 Jul 2005 12:39:23 +0000
Subject: note 55323 added to function.ereg
Groups: php.notes 
Request: Send a blank email to php-notes+get-92758@lists.php.net to get a copy of this message
In relation to the previous poster's comments: "Beware that eregs in PHP4 are broken, for instance if you want to match "a to z, 0,9 and -" you might want to use [a-z0\-9] but it will silently fail due to a bug : the \ don't escape some special chars, so this regexp is equivalent to [a-z0-9] ! Also putting \[ or \] inside the brackets (to match for a bracket) doesn't work, or raises an error, but curiously putting the \- at the end works. So if you want to match '[a-z\|\[\]]' you have to type '([a-z]|\-|\[\|])'" To make the backslash escape character work with ereg you simply need to just use \\. For instance the example the user gave: "a to z, 0,9 and -" And used the syntax "[a-z0\-9]" you would simply change it to "[a-z0\\-9]" and it works fine. ---- Submitter IP: 12.160.245.96 ---- Manual Page -- http://www.php.net/manual/en/function.ereg.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55323 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55323&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55323&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55323&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55323&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55323&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55323&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55323&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#92758) next »