Re: Warning: eregi() [function.eregi]: REG_ERANGE in ...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



OK, I don't think I searched the web hard enough. I've not found a
definitive explanation, but I think the warning has something to do
with the dash symbols (\-) within the square brackets. Removing them -
changing them to the regular expression below - removes the warning

'^[a-zA-Z0-9_.]+@[a-zA-Z0-9]+\.[a-zA-Z0-9.]+$'

Question is now, how am I supposed to match dash symbols?

In one thread I read advised preg functions using the ereg functions.
I had ago with this, putting back in the dashes and changing the
regular expression to a perl RE:

'/^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$/'

No warnings this time and it appears to work. I still welcome any
feedback on ereg if anyone wants to give any.

On 17/01/2008, Dan Stevens (IAmAI) <dan.stevens.iamai@xxxxxxxxx> wrote:
> I'm have trouble with some code that I have been following in a book
> regarding regular expressions. I'm attempting to validate an email
> using a regular expression. Below is a simplified version of the code
> which reproduces the problem I'm having:
>
> <?php
>         define("EMAIL_RE", '^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$');
>         $email = trim($_GET['email']);
>         $result = eregi(EMAIL_RE, $email);
>         echo $result . "<br />\n";
>         if ($result) echo "Email valid";
>         else "Email invalid"
> ?>
>
> Calling this code with the argument get=bob@xxxxxxxxxxx, I'd expect an
> interger output something like this
>
> 15
> Email valid
>
> Yet instead, all get is a warning that I cannot fathom and nothing else:
>
> Warning: eregi() [function.eregi]: REG_ERANGE in C:\Documents and
> Settings\daniel.stevens\My
> Documents\Workspace\htdocs\tutoring\eregi_test.php on line 4
>
> I've tried searching for this warning to find out what it means, but I
> cannot find any reference to it on the web. Is anyone able to tell me
> what this warning means and why I am not getting the output I'm
> expecting? Can anyone advise how best to find out what a particular
> error or warning means so I don't have to ask on this list everytime I
> come across one that means nothing? php.net does not appear to have a
> list.
>
> Thanks in advance.
>

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux