I can’t seem to figure out what reg. expr. notation fits my needs:
I have wrapped some debugging code in DEBUG() macros…
so for example to print some debug output in log level 1 i use the following bits of code:
DEBUG_LVL_1(printf("some text");)
This is not always and everywhere the case though – sometimes I have the printf statements without a macro wrapper.
I want to do a search and replace for those case… i.e. where there is NO DEBUG_LVL_ macro , but there exist a printf statement…
how do I do that?
If lookaheads are supported in your language/tool of choice you can use
(?!^.*DEBUG_LVL_1)is a negative lookahead assertion, this will fail ifDEBUG_LVL_1is found somewhere in the string.So this regex will match
printf, but only if there is noDEBUG_LVL_1somewhere in the same row.See it here on Regexr