Advertisement
Guest User

02.Extract Sentences by Keyword

a guest
Oct 28th, 2017
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace _02.ExtractSentencesByKeyWord
  5. {
  6.     class ExtractSentencesByKeyWord
  7.     {
  8.         static void Main()
  9.         {
  10.             string word = Console.ReadLine();
  11.             string[] text = Console.ReadLine().Split(new char[] { '.', '!', '?' }, StringSplitOptions.RemoveEmptyEntries);
  12.  
  13.             foreach (string sentence in text)
  14.             {
  15.                 string[] words = sentence.Split(new char[] { ' ', ',', '<', '>', '/', '\\', '/', '@', '#', '$', '%', '^', '&', '*', '(', ')', '[', ']', '{', '}', '|' });
  16.  
  17.                 if (words.Contains(word))
  18.                 {
  19.                     Console.WriteLine(sentence.Trim());
  20.                 }
  21.             }
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement