Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RegExp hex colour 2

Status
Not open for further replies.

Fendal

Technical User
Sep 13, 2005
178
GB
Hi,

Could somebody tell me the regular expression for matching hex colour codes,

Code:
var string="blah #000000 test #FF0000 blah #eeff00";

I know that " \d{6} " is six digits but it's not always digits only.
 
currently using " /\#\S{6}/g; ", but there must be a better way.
 
How about:
Code:
\#[0-9A-F]{6}

Course that doesn't cover three character color codes...

barcode_1.gif
 
Don't forget ignorecase, or #abcdef won't work.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top