I suppose this could fall into any language category that utilizes regular expressions;

Anyways, I'm trying to do a simple test on a string (a username) to ensure that it only contains 6 to 20 alphanumeric characters.

My pattern line is as follows:

Code:
$pattern = "/[A-Za-z0-9]{6,20}/";
Now, it works sort of, but if someone were to enter a string such as this:

Code:
abcdef&
It doesn't catch the ampersand. It only seems to care about the first 6 characters being alphanumeric (It happens with &, *, %, spaces, etc.) Now, I'm new with regex, but I can't seem to understand what I'm missing. Anyone?