public
Last active

Often used regular expressions

  • Download Gist
snippet.rb
Ruby
1 2 3 4 5
# Often used regular expressions - Cheatsheet
EMAIL = /\A[a-z0-9\+\-_\.]+@[a-z0-9]+[a-z0-9\-\.]*[a-z0-9]+\z/i
HOST = /\A[a-z0-9]+[a-z0-9\-\.]*[a-z0-9]+\z/i
URL = /(http|https):\/\/[\w\-_]+(\.[\w\-_]+)*([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/
HEX_COLOR = /\A([a-fA-F0-9]{3}){1,2}\z/

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.