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

One thought on “How to validate hex value with regex”

Leave a Reply