I'm fairly inexperienced with regex, but I need one to match the parameter of a function. This function will appear multiple times in the string, and I would like to return a list of all parameters.
The regex must match:
- Alphanumeric and underscore
- Inside quotes directly inside parenthesis
- After a specific function name
Here's an example string:
Generic3(p, [Generic3(g, [Atom('_xyx'), Atom('y'), Atom('z_')]), Atom('x_1'), Generic2(f, [Atom('x'), Atom('y')])])
and I would like this as output:
['_xyx', 'y', 'z_', x_1', 'x', 'y']
What I have so far:
(?<=Atom\(')[\w|_]*
I'm calling this with:
import re
s = "Generic3(p, [Generic3(g, [Atom('x'), Atom('y'), Atom('z')]), Atom('x'), Generic2(f, [Atom('x'), Atom('y')])])"
print(re.match(r"(?<=Atom\(')[\w|_]*", s))
But this just prints None
. I feel like I'm nearly there, but I'm missing something, maybe on the Python side to actually return the matches.