开发者

Regex I copied into my Rails model won't work?

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 开发者_Python百科tCARET. What's the problem?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜