SHARE
TWEET

02.Extract Sentences by Keyword

a guest Oct 28th, 2017 151 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top