Hi!
Can anyone help me with eregi?
I'm trying to validate IRC nicknames.
They can start with a-zA-Z[]{}_-^|
and the next symbols can be a-zA-Z0-9[]{}_-
|

I use the following code to check this:

if ((eregi("[]a-z{}\|[_-]([]a-z0-9{}^\\|[_-])*", $unick) == 0) || (strlen($unick)>15)) { echo "Invalid nick"; }

BUT... when I enter asd# for example
it returns me that this is valid nickname.
What am I doing wrong?

    this is what i'm using: (by detuned)

    $allowedchars = "]a-zA-Z0-9`-_{}|[";
    if (ereg("[".$allowedchars."]",$username))
    return "invalid characters in username ( use irc-legal chars: ".$allowedchars." )";

      10x for the help

      i just copy/paste your code
      and enter - adsfsd## for nickname.
      well, the same result - it seems that
      this is 'valid' nickname
      if i enter # as the first symbol - no problem
      but if it is second or etc. - the problem occurs
      10x again for da help

        Write a Reply...