开发者

Regex for VS Find and replace - empty else blocks

We have recently replaced a bunch of code in our solution leaving us with a lot of empty else statements. I'd like to do a find and replace all using a regex string an开发者_JS百科d was wondering if anyone could produce a Regex to use in VS2010's find and replace to find all patterns matching the code below:

 else
            {}

I've tried to modify some of the patterns i've found in other questions relating to empty catch blocks on stackoverflow to no avail.

Thanks!


else[\n:b]*\{[\n:b]*\}

this says look for else, followed by any white space or line breaks, then { followed by any white space or line breaks then }

Matches any of the following:

else{}    //No breaks
else {  } //Space in between
else{     //Single line break
}
else      //Muliple line breaks
{

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜