开发者

Regex for VS Find and replace - empty else blocks

开发者 https://www.devze.com 2023-03-22 11:31 出处:网络
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

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

精彩评论

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

关注公众号