Non-greedy multiline regex for functions

Make the regex faster while keeping multiline support.

Tested by @tacahiroy
```
10,000 lines:
    Current regex:
        15.352472
    Improved regex (by @dusans):
        0.240578
```