Reputation: 3642
I have tried:
$ grep -Po "def[[:space:]]+\K(.*)\(" code.py
The output should be a list of function names.
I think it should be correct, but it's only capturing one extra bracket. I would like to get rid off it in the expression (not postprocessing). Please, explain the syntax, you will use.
Upvotes: 0
Views: 277
Reputation: 34924
You can omit the "(" from the resulting string by putting it in a lookahead (?=<expression>)
:
grep -Po "def[[:space:]]+\K(.*)(?=\()" code.py
Upvotes: 1