Regex. Reject space

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shapper

    #1

    Regex. Reject space

    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
  • Jeff Johnson

    #2
    Re: Regex. Reject space

    "shapper" <mdmoura@gmail. comwrote in message
    news:83563c0d-6800-4561-a09f-d594e9b52b20@l4 2g2000hsc.googl egroups.com...
    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.)


    Comment

    • Steve

      #3
      Re: Regex. Reject space

      "shapper" <mdmoura@gmail. comwrote in message
      news:83563c0d-6800-4561-a09f-d594e9b52b20@l4 2g2000hsc.googl egroups.com...
      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
      There is a free tool: http://www.radsoftware.com.au/regexdesigner/ that I
      use for sorting out regular expressions.

      I hope this helps,
      Steve




      Comment

      • Hans Kesting

        #4
        Re: Regex. Reject space

        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
        RequiredFieldVa lidator.

        Hans Kesting


        Comment

        Working...