検索基準がある場合:She likes to watch tv
text.txt
いくつかの文を含む入力ファイル、例えば:
I don't know what to do. She doesn't know that it's not good for her health. She likes to watch tv but really don't know what to say. I don't blame her, but it's not her fault. This was just a test text. This is the end.
テキストファイル内の文字列を検索し、文字列を含む文とその前後の文を返したい。
出力は次のようになります。
She doesn't know that it's not good for her health. She likes to watch tv but really don't know what to say. I don't blame her, but it's not her fault.
そのため、一致した検索語の前の文、検索語を含む文、検索語の後の文を出力します。