kaloon
kaloon

Reputation: 167

regular expression to extract multiline line from a file in Python

I am trying to write a regular expression to extract multiline line from a file that has system call trace. I try to find a system call trace for the error that happens. It is a debugging project. My goal to extract all line between keywords "Before Error" and "After Error" Here are my tries. https://repl.it/@kaloon/LiquidDimgrayParser

May I know what a problem with it?

Upvotes: 1

Views: 54

Answers (1)

Tim
Tim

Reputation: 2843

Something like the following should work for you:

import re
pattern = re.compile(".*Before Error(.*)After Error.*", re.DOTALL)
pattern.findall(str1)

Upvotes: 1

Related Questions