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

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

 



Hi

> 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?

The problem is that you included the "\-" within SINGLE quotes. Escaping
a character only works within double quotes.  Go back to your original
but substitute the ' for " around the expression. Like this:

define("EMAIL_RE", "^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+$");

> 
> 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.

--
Niel Archer

-- 
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