views:

27

answers:

1

Brand spanking new to Regex in Rails so please be gentle... I found the following on Regexlib.com to validate no spaces.

^[a-zA-Z]+$

But when I put it into

validates_format_of :first_name, :with => ^[a-zA-Z]+$

I get an error saying unexpected tCARET. What's the problem?

+4  A: 

The syntax for a regex in Ruby is /regex/. So in your case /^[a-zA-Z]+$/.