--- David Halliday <[EMAIL PROTECTED]> wrote:
> Hi
>
> I have this simple code that rejects certain
> characters :
>
> if (ereg('([/[EMAIL PROTECTED]&*-_()|:;<>?"])', $name))
> {
> echo 'not allowed';
> }
>
> Trouble is that it also rejects the dot or period (.)
> yet the dot is not included in the class above
>
> What can be added to that criteria to make it *allow*
> the dot? Would appreciate your help.
>
> David
In a regular expression character class -- a list or sequence of characters
listed in square brackets -- the dash is used for a range of characters if the
character to the left of the dash has a lower ASCII value than the character on
the right of the dash. You have:
*-_
The * is 42 decimal and the _ is 95. In that sense, any capital letter would
also "match" and be denied.
To solve this, put your dash at the end of the list in square brackets so it is
treated as a literal rather than its special meaning.
James Keeline