Last active
September 27, 2015 15:28
-
-
Save delameko/1291391 to your computer and use it in GitHub Desktop.
Useful regular expressions for Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Useful regular expressions | |
# http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/ | |
# username | |
/^[a-z0-9_-]{3,16}$/ | |
# password | |
/^[a-z0-9_-]{6,18}$/ | |
# Hex value | |
/^#?([a-f0-9]{6}|[a-f0-9]{3})$/ | |
# Slug | |
/^[a-z0-9-]+$/ | |
/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/ | |
# URL | |
/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/ | |
# IP Address | |
/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ | |
# HTML Tag | |
/^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment