REGEXES = [(re.compile(r'cat'), 'cat2'),
(re.compile(r'(if)(.*)(\r?\n)(\s*)(logger.info)(.*)'), '\1\2')]
for search, replace in REGEXES:
line = search.sub(replace, line)
Why is it not working on…
if( List != null ) {
logger.info( "List is not null" );
fieldSetContainerList.clear();
}
Works fine with Notepad++ regex search replace.
Usage: Want to remove logger.info statements below all if statements.
You need to use a raw string:
With this fix, your regex works for me. Without it, the
\1and\2are processed when the string literal is parsed, and never make it to the regex engine.Here is my test code:
When run, this prints