Skip to content
Mkyong.com
Mkyong.com
  • Development Service
  • Spring Boot
  • Java 8
  • Contact

hex color code

Java regex hex color code

November 9, 2020October 23, 2009 by mkyong

This article shows how to use regex to validate a hex color code. Regex for hex color code. ^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$ Regex explanation ^ # start of the line # # start with a number sign `#` ( # start of (group 1) [a-fA-F0-9]{6} # support z-f, A-F and 0-9, with a length of 6 | # …

Read more

Categories regular expressions Tags hex, hex color code, java regex, regex 3 Comments

Mkyong.com has provided Java and Spring tutorials, guides, and code snippets since 2008. All published articles are simple, easy to understand, and well-tested in our development environment.

Mkyong.com licenses all source code on this website under the MIT License.

Tools
  • Spring Framework
  • Quarkus Framework
  • Micronaut Framework
  • Oracle Java JDK
  • Eclipse Temurin JDK
  • OpenJDK JDK
  • Hibernate ORM
  • Maven Build Tool
  • Gradle Build Tool
  • Tomcat Application Server
  • Docker
Links
  • Spring Guides
  • Docker Hub
  • Maven Central
  • Keep A Changlog
  • Semantic Versioning
  • Hugging Face - Qwen
  • Martin Fowler
About
  • About Us
  • Code License
  • Privacy Policy
  • Terms Of Use
  • Contact Us
© 2026 Mkyong.com - Build with Love.