For example:
AA33FF = valid hex color
Z34FF9 = invalid hex color (has Z in it)
AA33FF11 = invalid hex color (has extra characters)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Without transparent support:
With transparent support :
To elaborate:
^ ->match beginning# ->a hash[0-9A-F] ->any integer from 0 to 9 and any letter from A to F{6} ->the previous group appears exactly 6 times[0-9a-f]{0,2} ->adding support for transparent ( 00..FF)$ ->match endi ->ignore caseIf you need support for 3-character HEX codes (no transparent supported) , use the following:
The only difference here is that
is replaced with
This means that instead of matching exactly 6 characters, it will match exactly 3 characters, but only 1 or 2 times. Allowing
ABCandAABBCC, but notABCDCombined solution :