I have this ruby regex for validate that the user enter meta keywords separated by commas.
validates_format_of :tags, :with => /^\s*[A-Za-z0-9]+(\s*,\s*[A-Za-z0-9]+)*\s*$/u
I want add 2 conditions more to this regex:
-
limit the keywords to 4 keywords.
-
Add spanish characters like
ñáéíóúwithp{L}\s\p{N}
How can add this 2 conditions to this regex?
Thank you
Hey I think this regex will do the trick.
You can put your validation like this:
Or with the
validatesmethodBoth will do the same
NOTE: You should check Rubular, it is a great Ruby regex online editor