Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- namespace SentenceExtractor_4
- {
- class SentenceExtractor_4
- {
- static void Main(string[] args)
- {
- string word = Console.ReadLine();
- string text = Console.ReadLine();
- Regex line = new Regex(@"(\S.+?[.!?])(?=\s+|$)");
- MatchCollection matches = line.Matches(text);
- var list = matches.Cast<Match>().Select(x => x.Value).ToList();
- list.RemoveAll(a => !a.Contains(word));
- list.ForEach(b => Console.WriteLine(b));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment