PHIL Sawyer
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
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Thanks and welcome...
when business is getting demanding, I tend to loose attention for EE-Ruby :-)
when business is getting demanding, I tend to loose attention for EE-Ruby :-)
ASKER
Thanks
ASKER
Welcome back - brilliant answer as usual & works a treat.