How do I replace in Notepad ++ (plus plus) #******
with #FFFFFF
?
Basically if my code contains #000000
#0F0F0F
#5tfd5g
and so on, I want every one replaced with #FFFFFF
Turn on Regular Expression mode in the Find/Replace dialog.
Find what: #[A-Fa-f0-9]{6}
Replace with: #FFFFFF
NOTE: This will only find valid hexadecimal values, not the ill-formed #5tfd5g
.
#1234567
and similar should be treated? Should it become #FFFFFF7
or #FFFFFF
? It may be worth adding a \b
at the end of the find what text, making it #[A-Fa-f0-9]{6}\b
. Depending on exactly what is wanted, the find what text might be changed to #[A-Fa-f0-9]+\b
, #[A-Fa-f0-9]+
, #[A-Fa-f0-9]{6,}\b
or #[A-Fa-f0-9]{6,}
Jul 17, 2013 at 12:37
#[A-Fa-f0-9]{6}\b
might be what OP is looking for: a legal hex color spec. Although, #[A-Fa-f0-9]{3}\b
is also legal. That's the shortened version where #333
is interpreted as #333333
and could be replaced as either #FFF
or #FFFFFF
.
Jul 17, 2013 at 13:23
Use the "regular expression" find/replace in NP++:
the .
character says "anything", so #......
is #
followed by any 6 chars. You can use other regex tricks to get more specific if required.
You can use Regular Expressions inside notepad++
In the Replace
screen, in the left-bottom, you'll be able to change the radio-button to Regular Expression
In the find
option, put #.{6}
and in the replace
, put #FFFFFF