ID: 11461
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
-Status: Open
+Status: Bogus
Bug Type: Regexps related
Operating System: Linux 2.2.16-SMP
PHP Version: 4.0.6RC3
New Comment:
A bracket expression is a list of characters enclosed in
`[]'. It normally matches any single character from the
list (but see below). If the list begins with `^', it
matches any single character (but see below) not from the
rest of the list. If two characters in the list are sepa�
rated by `-', this is shorthand for the full range of
characters between those two (inclusive) in the collating
sequence, e.g. `[0-9]' in ASCII matches any decimal digit.
It is illegal- for two ranges to share an endpoint, e.g.
`a-c-e'. Ranges are very collating-sequence-dependent,
and portable programs should avoid relying on them.
To include a literal `]' in the list, make it the first
character (following a possible `^'). To include a lit�
eral `-', make it the first or last character, or the sec�
ond endpoint of a range. To use a literal `-' as the
first endpoint of a range, enclose it in `[.' and `.]' to
make it a collating element (see below). With the excep�
tion of these and some combinations using `[' (see next
paragraphs), all other special characters, including `\',
lose their special significance within a bracket expres�
sion.
Previous Comments:
------------------------------------------------------------------------
[2001-06-13 05:25:01] [EMAIL PROTECTED]
I tried to check email with
$check =
ereg('^[0-9A-Za-z_\-\.]+@[0-9A-Za-z_\-]+\.[0-9A-Za-z_\-\.]+[0-9A-Za-z_\-]+$',$email);
This does not work with '[EMAIL PROTECTED]', for example, althoug the
regular expression is correct. It works this way in any other
programming language.
But if you write it in the following way it also works fine in PHP:
$check =
ereg('^[\.0-9A-Za-z_\-]+@[0-9A-Za-z_\-]+\.[\.0-9A-Za-z_\-]+[0-9A-Za-z_\-]+$',$email);
Maybe the parser thinks of "-" as the range separator, althoug it is
written as \- ?
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=11461&edit=1