Sure it can. When you find the match you've the previous few lines, and can print them. The technique is just to show you how to keep track of the last few lines, in case you need to save some history.
Update: When I first read your post, I thought you wanted the code to predict the future!
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re^3: printing several lines around match
by roboticus
in thread printing several lines around match
by auto_w
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |