[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Regex problem

Posted on 2012-03-14
4
Medium Priority
?
259 Views
Last Modified: 2012-03-15
Hello,

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:
.*?:#[0-9a-f]{6}.

but how can I do this for every block in the string within the regex?
0
Comment
Question by:Marc_Engrie
  • 2
4 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37721929
What do you mean by "validate"? Your pattern should match each occurrence.
0
 
LVL 85

Accepted Solution

by:
ozo earned 500 total points
ID: 37721933
/^[^#]*#[0-9a-f]{6}( +[^#]*#[0-9a-f]{6})*$/
0
 

Author Comment

by:Marc_Engrie
ID: 37722030
working

Thx!
0
 

Author Comment

by:Marc_Engrie
ID: 37724517
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  [^#]
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question