Link to home
Start Free TrialLog 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
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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