Validate against special characters *; ' * ^ } { [ ] ><|

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

On 10/19/06, newbie [email protected] 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.