Having notepad++ autohighlight certain values when they are non zero
-
I use Notepad ++ to analyze error logs. One piece of information i look for is clipping duration greater than zero. It indicates the microphone volume needs adjusted. I appears in the log as so:
SigQual[ uD 1633 | Nd 0 | sN 16 |** cD 0** | wF 0x00 | aF 0x00 | dA 0.0 [63561] | sA 14.6 [5882] | Rt D ]
I have bolded the cD part for emphasis.
Here is my question, how can I have notepad++ highlight any non zero value when it occurs next to the letters cD.
I am not a programmer, BTW. Your explanation might need to be relatively non technical for me to understand.
-
Hello, @matthew-millard,
Not too difficult with the right regular expression !
So, using, for instance, the example text, below :
SigQual[ uD 1633 | Nd 0 | sN 16 | cD 23 | wF 0x00 | aF 0x00 | dA 0.0 [63561] | sA 14.6 [5882] | Rt D ] SigQual[ uD 1633 | Nd 0 | sN 16 | cD 0 | wF 0x00 | aF 0x00 | dA 0.0 [63561] | sA 14.6 [5882] | Rt D ] SigQual[ uD 1633 | Nd 0 | sN 16 | cD 1 | wF 0x00 | aF 0x00 | dA 0.0 [63561] | sA 14.6 [5882] | Rt D ] SigQual[ uD 1633 | Nd 0 | sN 16 | cD 127 | wF 0x00 | aF 0x00 | dA 0.0 [63561] | sA 14.6 [5882] | Rt D ] SigQual[ uD 1633 | Nd 0 | sN 16 | cD 0 | wF 0x00 | aF 0x00 | dA 0.0 [63561] | sA 14.6 [5882] | Rt D ] SigQual[ uD 1633 | Nd 0 | sN 16 | cD 1234 | wF 0x00 | aF 0x00 | dA 0.0 [63561] | sA 14.6 [5882] | Rt D ]
-
Open the Find dialog ( CTRL + F )
-
In the Find what: zone, type in the regular expression, below :
(?-i)(?<= cD )(?!0 )\d+
-
Check the Wrap around option
-
Select the Regular expression serach mode ( IMPORTANT )
-
Click on the Find Next button
=> You should get the next number, different from 0, located after the string cD, in that exact case. Et voilà !! ( only the second and fifth lines will be skipped ! )
Notes :
-
The first part
(?-i)
forces the regex engine to search, in a sensitive way ( = non-insensitive ) -
The final part
\d+
is the real string to search for, that is to say, a digit (\d
), repeated one or more times (+
) ( idem a number ! ) -
But, this number will be matched by the regex engine, IF and ONlY IF the two following conditions are TRUE :
-
Before the number location, the string
" cD "
, with two spaces and without doubles quotes, DO exist ( positive look-behind syntax :(?<= cD )
) -
At number location, the string
"0 "
, with one space and without doubles quotes, does NOT exist ( negative look-ahead syntax :(?!0 )
)
-
Best Regards,
guy038
-