froggy regex

If there's an instance where an expression is likely to return a false positive over a false negative, we have preferred the false positive. To validate data properly where false positives are not acceptable, you should do a secondary validation, such as emailing or calling the entered value, or using a validation API.

ISBN number:

Identifies a valid ISBN number. If the entry is 10 digits and has nothing but numbers, accept it. If it's 13 characters, the 1st three should be 978 or 979, and it can have a '-' inbetween the 1st three numbers and the last 10. ^(97(8|9))?(-)?\d{9}(\d|X)$

Invalid.

Email:

Checks if an entered email is valid. This should include uncommon email formats as well. Check for an unlimited number of characters matching A-Z, a-z, 0-9, -, +, ., and _. Then check for @, then check for an unlimited number of characters matching A-Z, a-z, 0-9, ., and -. Then check for '.'. Finally check for an unlimited number of characters longer than 2, matching A-Z, a-z, ., and 0-9. [A-Za-z0-9.\-\+_]{1,}[@][A-Za-z0-9.\-]{1,}[.][A-Za-z0-9.]{2,}

Invalid.

Phone number (international format):

Validates a phone number, allowing for a '+' at the start, '(' and ')' for the 1st four numbers, and '-' anywhere after that. Due to complications in how phone numbers and country codes are assigned, it's impractical to limit the length of the number. ^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\./0-9]*$

Invalid.

Hexadecimal colour code:

Validates a hexadecimal colour code. Allows a '#' at the start, and three or six characters matching a-f, A-F, and 0-9. ^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$

Invalid.

RGB colour code:

Validates a rgb colour code. Allows '(' at the start, and ')' at the end. Limits the three numbers to being between 0 and 255. ^(?:(?:^|\(|,\s*)([01]?\d\d?|2[0-4]\d|25[0-5])){3}\)?$

Invalid.

MasterCard:

Validates a MasterCard number. 5[1-5][0-9]{14}

Invalid.