<pre><code>if(!eregi("^([0-9a-z_\[\]\*\- ])+$", $subuser))
    $form-&gt;setError($field, "* Username not alphanumeric");
</code></pre>

<p>Can anybody tell me why it is not allowing characters such as <code>-</code> and <code>*</code>?</p>

<pre><code>if(!eregi("^([0-9a-z])+$", $subuser))
    $form-&gt;setError($field, "* Username not alphanumeric");
</code></pre>

<p>That is the original piece of code. A friend changed it to the top piece and it will allow a-z and 0-9 but it wont allow the other characters I need it to. Can anyone help me?</p>

<p>Thanks in advance.</p>

Your regex uses PCRE syntax, so you have to use preg_match() instead of eregi().
Try this code instead:
```
```
else if (!preg_match("/^([0-9a-z_\[\]* -])+$/i", $subuser)) {
$form->setError($field, "* Username not alphanumeric");
}
```
```