I am new to Regex. I am trying to get multiple lines after a string match. Somehow I able to do it, but I feel like that is not the best way. The following code produces a list of a tuple of the next 10 lines and the tenth line.
re.findall(r'(Input orientation(.+\n){10})',f)
- Would you please explain how it happened and how can I get a list of matched line and next n lines.
- Is there have any way to print m-th to (m+n)th line after matching a string? eg. print 5th to 10th line after matching the string "Input orientation"
I am looking for a regex solution only.
Thanks much