I have some code containg null == myvar and want to change it myvar == null. Variants of code
if(null == myvar) > if(myvar == null)
if(null != myvar) > if(myvar != null)
if(null == myvar && someother) > if(myvar == null && someother)
if(null == foo.SomeFoo(bar).FirstOrDefault()) > if(foo.SomeFoo(bar).FirstOrDefault() == null)
I have solved the 3 first cases using this regex
null ([!=]{2}) (.*?)([ \)])
And replace with
$2 $1 null$3
Though for the last case it will replace with
if(foo.SomeFoo(bar)==null.FirstOrDefault())
The problem is it looks for a space or a parenthesis, but in the case of parenthesis it needs to balance them with opening parenthesis
I need to use Balancing Groups somehow but I do not understand how :D