Solved

Regex problem

Posted on 2012-03-14
4
254 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 84

Accepted Solution

by:
ozo earned 125 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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

724 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