views:

30

answers:

2

R# 5.1.1751.8

When I perform a pattern search for...

catch (Exception e) {}

...I'm shown an error dialog which says "Can not parse pattern".

What about that pattern cannot be parsed? What am I doing wrong?

A: 

The ()s and {}s are special characters for regular expressions, so they need to be escaped with leading backslashes:

catch \(Exception e\) \{\}
Paul McGuire
This gives me the same error.
lance
Ouch, rough crowd! I assumed from the "Re" in ReSharper that we were doing something with re's, that is to say, regular expressions. No reason to bite my head off/downvote me...
Paul McGuire
+2  A: 

I emailed JetBrains support and got the following response:

ReSharper cannot parse only part of a C# language construct. In this case, 'catch(Exception e){}' is part of a try/catch construct. The following will search for empty catch clauses:

try {
    $stmt$
}
catch(Exception e)
{
}

( where $stmt$ is "one or more statements" ).

lance