I Have a text starting with 3 digits of code I have written a logic to capture the current line but I need to capture the next 5 lines continuously
import re
newtxt="200 sample text with many lines\n hell01 \n hell02 \n hell03 \n hell04 \n hell05\n hell06\n hell07 \n hell08"
text = re.compile(r'^\d{3} [a-z].*')
for line in newtxt.split('\n'):
if text.match(line):
print(line)