Question about validates_format_of

I'm trying to make sure that a name contains no funky characters. Is
there some obvious reason why the following lines would have no effect?

  validates_format_of :name, :with => %r{\w*}
  validates_format_of :name, :with => %r{([A-Za-z])*}

With these lines in my model, I can enter almost any name (with
blanks, punctuation, etc.) and Rails accepts it.

On the other hand, if I add

  validates_format_of :name, :with => %r{.*\.jpg}
  validates_length_of :name, :minimum => 2

then rails rejects short names or names that don't end in .jpg.

Because * means zero or more matches. You probably want to use + (one or more

Actually, I forgot the ^ and $. That's what made this regex match
almost anything.