note 57387 deleted from function.ereg by tularis

From: Date: Thu, 31 May 2007 13:23:48 +0000
Subject: note 57387 deleted from function.ereg by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-127066@lists.php.net to get a copy of this message
Note Submitter: Jason knarlin at yahoo dot com dot au ---- A previous post stated "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" This is incorrect, this is not a bug, nor is ereg broken on this count! In my testing of ereg, matching -' [' or `]' within a bracketed expression ereg works exactly according to the regex man page http://www.tin.org/bin/man.cgi?section=7&topic=regex referred from the php manual page at http://au3.php.net/manual/en/ref.regex.php From the regex man page you will find that within a bracketed expression to match a literal ]' make it the first character (following a possible ^'). To include a literal -' make it the first or last character, or the second endpoint of a range. To use a literal -' as the first endpoint of a range, enclose it in [.' and .]' spook says if you want a string to work that matches "a to z", "A to Z", "0 to 9", "-", "[", "]" and "_" you will have to use this expression: ([0-9a-zA-Z_]|\-|\[|\]) end spook says A neater solution is []0-9a-zA-Z_[-] I hope this settles that ereg is not buggy or broken in this regard (I reposted as the preview on this board misled me, I thought I had to escape \ )

« previous php.notes (#127066) next »