Problem: I have to find valid hex colours in a file, but not to include any selectors that potentially might conflict with it.
For example, in the below code,
#Cab
{
background-color: #ABC;
border: 2px dashed #fff;
}
#ABC
and #fff
are valid, but not #cab
.
Question:
Is it possible to put condition for substring before and after the intended string of search.
Here, i need this #[0-9a-fA-F]{3,3}|#[0-9a-fA-F]{6,6}
to be searched. But only if the substring immediately before it is :[\w\s]*
and substring immediately after it is \W
Note 1: I figured that searching for \W
after the string can be be done by adding \b
in the original search.
Note 2: This was a problem in python, and I could trim it through python, but wondering if there is a way to do this through regex.