Validate the format of a string of comma separated words with regex
问题 I'm trying to validate a string of comma separated words from a text field in a ruby class using regex. The following should be valid: word word, word, word word,word,word And the following should be invalid: word word word I thought this would work /([a-z]+){1}(,\s*[a-z]+)*/i On Rubular, it seems to be valid, but when I validate in my class as follows, it accepts what should be invalid strings. @tag_regex = /([a-z]+){1}(,\s*[a-z]+)*/i validates :tags, :allow_blank => true, :format => { :with