开发者

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

开发者 https://www.devze.com 2023-01-05 09:26 出处:网络
Brand spanking new to Regex in Rails so please be gentle... I found the following on Regexlib.com to validate no spaces.

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

精彩评论

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

关注公众号