I have a list of strings that look like
"funcname(arg, another_arg)*20 + second_func(arg1, arg2)"
and I want to pull out just the args. I’ve tried the following:
re.findall(r'\w[\w\d_]+(?!\()', string)
however this returns
['funcnam', 'arg', 'another_arg', '20', 'second_fun', 'arg1', 'arg2']
Firstly, I’m a bit confused as to why I am seeing the '20', since I specified the string should start with a word character. Secondly, I’m wondering how I can improve my look-ahead to match what I’m looking for.
I should note that some of the strings don’t have functions and look like
"value1 + value_two"
so I can’t simply search inside the parentheses.
1 Answer