How to validate hex value with regex

to validate hex value with regex you can use this snippet.

Sample RegEx

^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$

this regex will match:

#112233
#FF1122
#aaffDD

Please Share us:
Please rate this snippet

One thought on “How to validate hex value with regex

Leave a Reply