i''m sorry for posting such a stupid (and somewhat unconnected) question, but i''ve been stuck on this for over a couple good hours (probably due to a lack of knowledge in regexp) so if anyone could give a hand, i''d most appreciate it... i''m trying to validate my site against these characters ## thesechars ## *; '' * ^ } { [ ] >< | and so i''ve decided i''d use validates_format_of /^[^thesechars]$/ but it''s not working! is there a different method i should be using? many thanks, newbie -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Daniel N
2006-Oct-19 14:53 UTC
Re: validate against special characters *; '' * ^ } { [ ] ><|
On 10/19/06, newbie <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > i''m sorry for posting such a stupid (and somewhat unconnected) question, > but i''ve been stuck on this for over a couple good hours (probably due > to a lack of knowledge in regexp) so if anyone could give a hand, i''d > most appreciate it... > > i''m trying to validate my site against these characters > ## thesechars ## *; '' * ^ } { [ ] >< | > and so i''ve decided i''d use validates_format_of /^[^thesechars]$/My regexp kung-fu is not the strongest, but it looks like you''ve only allowed for a single charachter here. You may need to allow for some more validates_format_of /^[^thesechars]+$/ You may want to consider this around the other way though. Instead of forbidding chars, allow a restricted set. validates_format_of /^\w+$/ will restrict the values allowable (maybe too much so). You''ll need to check the docs to tune it to your specific need. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---