How to grab the lines AFTER a matched line in python
- by toofly
Hi All,
I am an amateur using Python on and off for some time now. Sorry if this is a silly question, but I was wondering if anyone knew an easy way to grab a bunch of lines if the format in the input file is like this:
"
Heading 1
Line 1
Line 2
Line 3
Heading 2
Line 1
Line 2
Line 3
"
I won't know how many lines are after each heading, but I want to grab them all. All I know is the name, or a regular expression pattern for the heading.
The only way I know to read a file is the "for line in file:" way, but I don't know how to grab the lines AFTER the line I'm currently on. Hope this makes sense, and thanks for the help!