I need to find method bodies in iOS source code. I've started from writing simple regex: \{.*\}
but things goes complex when I need to handle nested parentheses.
So I started to think from another direction. I tried to detect method declaration with something like this: [+-].+ \{
, so I can find end of method with next pattern: \}\s+[+-]
, but here's bad case for it:
- (void)method:(id)arg0 :(id)arg1 third:(id)arg3 {
...
}
#pragma mark - Bla-bla
- method2:(id)arg0 {
code(
{
});
if (1) {
}
-1;
}
Can you have any ideas or algorithms or regex to detect method bodies correctly?