Reputation:
Suppose I have a file with some hex colors:
.. #101010 .. match
.. #a2a2a2 .. match
.. #abcd10 .. do not match
.. #000000 .. match
.. #111222 .. do not match
.. #ffffff .. match
.. #3b3b3b .. match
.. #121012 .. do not match
.. #fff .. match
.. #aba .. do not match
How to select all hex-colors which red
, green
and blue
values are the same?
Thanks in advance.
Upvotes: 1
Views: 164
Reputation: 785761
You can use this regex:
#([a-fA-F\d]{1,2})\1{2}\b
\1
is back-reference of first 1 or 2 digits after #
RegEx Breakup:
# # Match a literal hash or #
([a-fA-F\d]{1,2}) # Match 1 or 2 hex digit and group it as captured group #1
\1{2} # Match 2 more occurrences of back-reference \1
\b # Assert a word boundary
Upvotes: 5