Re: Warning: eregi() [function.eregi]: REG_ERANGE in ...
| From: | Niel Archer | Date: | Sun, 20 Jan 2008 16:46:51 +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-28746@lists.php.net to get a copy of this message | ||
> I think single quotes is right because you don't want PHP to escape
> the characters...the escape is for regex, not PHP
In fact, we're neither correct, I was thinking of PCRE, but this is
POSIX regexes which I'm not familiar with.
From the POSIX man pages:
"To include a literal `]' in the list, make it the first character
(following a possible
^'). To include a literal -', make it the first
or last character, or the second 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 exception of
these and some combinations using `[' (see next paragraphs), all other
special characters, including `\', lose their special significance
within a bracket expression"
Which seems to tell us it can't be (and doesn't need to be) escaped at
all. I'll stick with PCRE, they're binary safe.
I would try removing the backslash and moving the hyphen to be the last
character in the range (after the full stop).
> On Jan 19, 2008 9:44 AM, Niel Archer <not@chance.now> wrote:
> > 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
> >
> >
>
>
>
> --
> ts2do
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
Niel Archer