Link to home
Create AccountLog in
Avatar of PHIL Sawyer
PHIL SawyerFlag for United Kingdom of Great Britain and Northern Ireland

asked on

find word then return thsat line plus next line

Hello

I have a large text file and want to filter rows where when a certain word (eg from) is found then I want that row and the very next returned - example..

mytext="
This is a test
and  the word I am looking to capture is
FROM
and this line should also be returned
this line should not be returned
or this one etcetc
From today
blah blah
and this line should also be returned
this line should not be
"

This is what should be returned from the regular expression ....
FROM
and this line should also be returned
From today
blah blah


Regards
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of PHIL Sawyer

ASKER

Gertone
Welcome back - brilliant answer as usual & works a treat.
Thanks and welcome...
when business is getting demanding, I tend to loose attention for EE-Ruby :-)
Thanks