Validate Email Address
by Kyle on · Posted in Regular Expressions
/^(([^<>()[\]\\.,;:\s@"\']+(\.[^<>()[\]\\.,;:\s@"\']+)*)|("[^"\']+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])|(([a-zA-Z\d\-]+\.)+[a-zA-Z]{2,}))$/
Validate US Social Security Number
by Kyle on · Posted in Regular Expressions
This regular expression accepts either 123-45-6789 or 123456789:
/^\d{3}\-?\d{2}\-?\d{4}$/
Validate US ZIP Code
by Kyle on · Posted in Regular Expressions
This regular expression accepts both 5- and 9-digit ZIP codes.
^[0-9]{5}(-[0-9]{4})?$
Validate MAC Address
by Kyle on · Posted in Regular Expressions
[:xdigit:]]{2}:){5}[[:xdigit:]]{2}
Validate IPv4 Address
by Kyle on · Posted in Regular Expressions
((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])
Validate URL
by Kyle on · Posted in Regular Expressions
/^(http:\/\/|https:\/\/|www\.)(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?(\/)*$/i
Validate Phone Number
by Kyle on · Posted in Regular Expressions
This regular expression accepts the following formats:
123456789123123456789123 123456789
^(\\+?)([0-9]+?)(\\s?)(\\+?)[0-9]+$