I want to grab the entire string after first bracket after specific pattern e.g. x.set(, to the last corresponding bracket to first bracket from x.set(, even searching between lines (get as much text as needed before find corresponding ending bracket). Example string:
"ver = '1.0'
if x.set('1.2'):
p = x.set('python_version', None)
x = x.set('test_template', DEFAULT, p(x,b),
z())"
The result i search for should be (using re.findall):
find_all_res = [['1.2'],['python_version', None],['test_template', DEFAULT, p(x,b),\nz()]
Now i'm using:
re.findall(pattern="(?<![0-9a-zA-Z_])x.set([\s\S]+?)(?<=[)])(\s)", string=value)
And the result i have:
find_all_res = [[("('1.2'):\n p = x.set('python_version')", '\n'), ("('test_template', DEFAULT, p(x,b),\n z())", '\n')]
UPDATE: