#27049 [NEW]: Regular Expression Syntax

From: Date: Mon, 26 Jan 2004 15:58:03 +0000
Subject: #27049 [NEW]: Regular Expression Syntax
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-53906@lists.php.net to get a copy of this message
From: al at lufthansa dot com Operating system: Linux PHP version: Irrelevant PHP Bug Type: *Regular Expressions Bug description: Regular Expression Syntax Description: ------------ The escaping the dash character (-) in a characters set of a regular expression is ignored. It works correctly in Perl. Reproduce code: --------------- <? // -*- C -*- echo "<html><body>"; $email = "test-user.lastname\@my-domain.com"; $email = "test-user.lastname+reference\@my-domain.com"; if (eregi( '^[a-z0-9]+[a-z0-9\-\.\+_]*\@([a-z0-9\-\.]+\.[a-z][a-z]+)$', $email)) { echo "Valid"; } else { echo "Invalid"; } echo "</body></html> "; ?> Expected result: ---------------- This should print valid, but prints invalid. I know the work around is to put the -, without the escape, at the end of the regex. Perl works correctly: #! /usr/bin/perl $_ = "test-user.lastname\@my-domain.com"; $_ = "test-user.lastname+reference\@my-domain.com"; if ( /^[a-z0-9]+[a-z0-9\-\.\+_]*\@([a-z0-9\-\.]+\.[a-z][a-z]+)$/) { print "Valid\n"; } else { print "Invalid\n"; } Also see http://bugs.php.net/bug.php?id=10741&edit=2 -- Edit bug report at http://bugs.php.net/?id=27049&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27049&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27049&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=27049&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=27049&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=27049&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=27049&r=needscript Try newer version: http://bugs.php.net/fix.php?id=27049&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=27049&r=support Expected behavior: http://bugs.php.net/fix.php?id=27049&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=27049&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=27049&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=27049&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27049&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=27049&r=dst IIS Stability: http://bugs.php.net/fix.php?id=27049&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=27049&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=27049&r=float

« previous php.bugs (#53906) next »