Can someone help me write the regular expression for validates_format_of.
It should fail if any one of
< > $ \ any_non_printable_character
is present.
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Something like this would work with Ruby 1.9:
That will match anything that doesn’t contain your bad characters and hence should work nicely in a validation. That will also match an empty string though so you could use
+instead of*or add a length orpresent?check if you wanted to exclude''.