From: Eric Hodel Date: 2006-09-02T11:22:34+09:00 Subject: Re: RegExp issues.... On Sep 1, 2006, at 7:14 PM, Timothy Hunter wrote: > Ben V. wrote: >> I am trying to validate user input so it contains only letters, >> numbers, underscores and dashes. I am using this regexp:/[A- >> Z0-9_-]/. However, when I type in 'hello' in the field, it says >> that it doesn't match the regexp, yet I'm sure that reg exp works >> for letters, numbers, and underscores only. What am I doing wrong? >> Thanks for your help and time. >> >> > Shouldn't your regexp accept lowercase as well? /[A-Za-z0-9_-]/? > > Or you could simplify things a bit and use \w, which matches word > characters, and \d, which matches digits? > > [\w\d_-] \w matches digits too '0' =~ /\w/ # => 0 -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com