I have a file formatted:
BEGIN
xxx
END;
BEGIN
xxx
EXCEPTION
xxx
END;
BEGIN
xxx
EXCEPTION
xxx
END;
What i need is only the data between only BEGIN and EXCEPTION block and ignore the BEGIN-END and EXCEPTION-END block. I have created a regex but its not giving me the desired output:
body=re.findall(r'BEGIN.*^[^BEGIN].*EXCEPTION', data, re.MULTILINE|re.DOTALL)
Also I want to remove the BEGIN and EXCEPTION from the output, can I do it through regex. Alternatively I can use replace function too. Pls help.