H
H
hidden_pingvin2015-04-19 14:14:11
Java
hidden_pingvin, 2015-04-19 14:14:11

How to solve a java problem with regular expressions?

The task itself:
Use a regular expression that determines whether the given string is a hexadecimal color identifier in HTML, but is not white (#FFFFFF) or black (#000000).
example of matches: #FFFFF1, #FF3421, #00ff00.
example of inconsistencies: 232323, f#fddee, #fd2, #ffffff.
About the second part of the task (with #FFFFFF and #000000), Google did not give any information. The task does not seem difficult, but I'm at an impasse.
I made this line:

Pattern regex = Pattern.compile("#((([\\dA-Fa-f]){6}))");

Tried to do like this:
Pattern regex = Pattern.compile("#((([\\dA-Fa-f]){6})&&[^(000000)] &&[^(ffffff)])");

But in this case, all entered expressions become false.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IceJOKER, 2015-04-19
@hidden_pingvin

~#[a-f\d]{6}(?<!#f{6}|0{6})~i

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question