Regular Expressions used to determine whether a color is valid (detailed description)
"^ # ([0-9a-fA-F] {6} | [0-9a-fA-F] {3}) $ ";
It indicates that it starts with # and is followed by a number and a-f characters (in upper or lower case). The value is 6 or 3 characters. Match a 3 to conform to the abbreviated css color rules:
"# Abc" = "# aabbcc"
Note: If you need to convert 16-bit and 10-bit values, for example, to convert the color value to int, there is a database. If it is a 6-bit color, there is no problem, if it is a 3-digit color, it will be wrong, because when you get it back, it will be converted from 10 hexadecimal
In hexadecimal notation, you don't know whether it should be three or six digits.
For example: # convert FF = to 10 hexadecimal => 255. If it is transferred back: 255 = to hexadecimal => ff, if you know it is 6 digits, you can add "#0000" to it and change it to "# 0000ff ", if it is three digits, it becomes "# 0ff"
Therefore, if you want to convert to a 10-digit storage, the three-digit color value should not exist, alternatively, convert the color value to a six-digit color value before saving it.
The above regular expression used to determine whether the color is valid (detailed description) is all the content shared by the editor. I hope you can give us a reference and support for the customer's house.