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
{
}
精彩评论