In other words, if you want your regular expression to match a hypen, it
must be the first or the last character within the :
Also, are you sure you want the * quantifier, as this will also match
the empty string. Using + may be what you are looking for in this case.
Rob B. wrote:
At 1/20/2006 01:52 PM, you wrote:
The pattern is really simple but I have this error :
SyntaxError in Login#register
./script/…/config/…/app/models/user.rb:6: invalid regular
expression: /^[A-z0-9_.- ]*$/
This is strange. I forgot something ?
You can’t have [.- ] because that looks like the range from ‘.’ to ’
’ and space is lower than full-stop.
Try: /^[A-z0-9 _.-]$/ or (as someone suggested: /^[A-Za-z0-9
_.-]$/ if you didn’t intend [ (0x5B), \ (0x5C), ] (0x5D), ^ (0x5E),
_ (0x5F), and ` (0x60) to be included between Z and a)