Regex problem


I have a string of multiple 'blocks' of colors in Hex notation. The number of blocks can vary from 1 to 9. each is separated with one or more spaces.

eg: string with 2 block  BLCK1:#222222 BLCK2:#333333
string with 4 blocks  BLCK1:#123456 TEXT:#654321 LINE:#334455 FONT:#214365

I want to validate such a string line against some basic rule:

but how can I do this for every block in the string within the regex?
Who is Participating?
ozoConnect With a Mentor Commented:
/^[^#]*#[0-9a-f]{6}( +[^#]*#[0-9a-f]{6})*$/
käµfm³d 👽Commented:
What do you mean by "validate"? Your pattern should match each occurrence.
Marc_EngrieAuthor Commented:

Marc_EngrieAuthor Commented:
Additional about this:

what needs to change in the regex in order to detect/allow besides

BLCKX#123456   also   BLCKX#12345678

but not  BLCK1:#1234567

What is the difference  between   .*?  (lazy)   and  [^#]
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.