使用正则表达式,我如何验证日期以确保它只以这种格式输入:mm/dd/yyyy?
如果有人感兴趣,我在 Ruby 模型中使用 validates_format_of :date_field, :with =>//
。
最佳答案
此格式的正则表达式如下所示:
^\d{2}\/\d{2}\/\d{4}$
关于ruby-on-rails - 使用正则表达式验证日期格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8173548/