Hex Color

Matches any hex color with #rgb, #rgba, #rrggbb, and #rrggbbaa formats.

Contributed by @itsbrunodev

regex
^#(?:(?:[\da-f]{3}){1,2}|(?:[\da-f]{4}){1,2})$
md
# Valid Hex Colors
#fff
#fff5
#ffffff
#ffffff50
 
# Invalid Hex Colors
#f
#ff
#fffff
GitHubEdit on GitHub