Guest User

Untitled

a guest
May 12th, 2015
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5. using System.Threading.Tasks;
  6.  
  7. namespace SentenceExtractor_4
  8. {
  9.     class SentenceExtractor_4
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string word = Console.ReadLine();
  14.             string text = Console.ReadLine();          
  15.                        
  16.             Regex line = new Regex(@"(\S.+?[.!?])(?=\s+|$)");
  17.             MatchCollection matches = line.Matches(text);
  18.             var list = matches.Cast<Match>().Select(x => x.Value).ToList();
  19.             list.RemoveAll(a => !a.Contains(word));          
  20.             list.ForEach(b => Console.WriteLine(b));
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment