DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

File Extension Regex

11.15.2007
| 4095 views |
  • submit to reddit
        
# returns nil if not found or numerical index if found
"dog.jpg" =~ /.*(jpg|png|gif)$/

validates_format_of :image_url, :with => %r{\.(gif|jpg|png)$}i