Validate Hex Color

Check if a string is a valid hex color code.

Code

General
import re
return bool(re.match(r'^#([0-9A-Fa-f]{3}){1,2}$', color))

Parameters

The hex color to validate

Server

More Python Snippets