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

William has posted 8 posts at DZone. View Full User Profile

Misc Ruby Regex

09.18.2009
| 6577 views |
  • submit to reddit
        URL with or without protocol (http or https)
/^((http|https?:\/\/)?((?:[-a-z0-9]+\.)+[a-z]{2,}))$/

Date format mm/dd/yyyy
/^(0[1-9]|1[012])[\/](0[1-9]|[12][0-9]|3[01])[\/][0-9]{4}$/

Limit string character
/^([a-z]|[A-Z]){1,3}$/