Regex. Reject space

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I have the following:
^([a-zA-Z0-9]{8,24})$

It accepts only letters and numbers as expected. But it also accepts
spaces. I don't want that.

What am I doing wrong?

Thanks,
Miguel
 
I have the following:
^([a-zA-Z0-9]{8,24})$

It accepts only letters and numbers as expected. But it also accepts
spaces. I don't want that.

What am I doing wrong?

That pattern looks fine. Post a working snippet of code that demonstrates
the problem. (Something we could paste into a console application and run to
test ourselves.)
 
shapper submitted this idea :
Hello,

I have the following:
^([a-zA-Z0-9]{8,24})$

It accepts only letters and numbers as expected. But it also accepts
spaces. I don't want that.

What am I doing wrong?

Thanks,
Miguel

Are you using this in an asp.net regexvalidator? That validator ignores
empty fields! If you don't want to allow an empty field, add a
RequiredFieldValidator.

Hans Kesting
 
Back
Top