Re: Warning: eregi() [function.eregi]: REG_ERANGE in ...
| From: | Niel Archer | Date: | Sat, 19 Jan 2008 15:44:08 +0000 |
| Subject: | Re: Warning: eregi() [function.eregi]: REG_ERANGE in ... | ||
| References: | 1 2 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-28743@lists.php.net to get a copy of this message | ||
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