ID:               27049
 Updated by:       [EMAIL PROTECTED]
 Reported By:      al at lufthansa dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         *Regular Expressions
 Operating System: Linux
 PHP Version:      Irrelevant
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

..



Previous Comments:
------------------------------------------------------------------------

[2004-01-26 10:58:02] al at lufthansa dot com

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 = "[EMAIL PROTECTED]";
$email = "[EMAIL PROTECTED]";

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

$_ = "[EMAIL PROTECTED]";
$_ = "[EMAIL PROTECTED]";

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 this bug report at http://bugs.php.net/?id=27049&edit=1

Reply via email to