Regular expression to check white space

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RuthC
    New Member
    • Nov 2007
    • 33

    Regular expression to check white space

    Hi, I use this regular expression to check alphanumeric with('_' and '-')
    Code:
    var regex_alphanumeric = /^[a-zA-Z0-9\-\_\s]{2,}$/;
    but It allows white space also.Now I want to check white space also.

    Please help me..


    Thanks in Advance..
    Ruth
  • Dasty
    Recognized Expert New Member
    • Nov 2007
    • 101

    #2
    So do you want or you dont want to check whitespaces?
    If you dont, just remove /s from your regular expressions, because /s represents all whitesspaces (space, tab, newline etc...)

    Code:
    var regex_alphanumeric = /^[a-zA-Z0-9\-\_]{2,}$/;
    Or make your request more clear pls.

    Comment

    • RuthC
      New Member
      • Nov 2007
      • 33

      #3
      Thanks Dasty,

      Actually i don't want white space..
      Now its working fine. Thanks for the help.

      Comment

      Working...