Marc_Engrie
asked on
Regex problem
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?
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?
What do you mean by "validate"? Your pattern should match each occurrence.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
working
Thx!
Thx!
ASKER
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 [^#]
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 [^#]