ID:               11461
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
 Status:           Bogus
 Bug Type:         Regexps related
 Operating System: Linux 2.2.16-SMP
 PHP Version:      4.0.6RC3
 New Comment:

No I didn't.  The problem has nothing to do with ^ vs. [^
The question is whether \- is a valid way to get a literal - inside
[]'s


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

[2002-05-14 16:05:56] [EMAIL PROTECTED]

@rasmus:

It sounds like you've mistaken "^" for "[^" ...

http://sunsite.utk.edu/gnu/regex/regex_17.html#SEC17
http://sunsite.utk.edu/gnu/regex/regex_23.html#SEC23

------------------------------------------------------------------------

[2002-05-14 12:31:25] [EMAIL PROTECTED]

 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.

------------------------------------------------------------------------

[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

Reply via email to