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;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- namespace _02.ExtractSentencesByKeyword
- {
- public class StartUp
- {
- public static void Main()
- {
- string word = Console.ReadLine();
- var pattern = @"\b" + word + @"\b";
- string[] sentences = Console.ReadLine()
- .Split(new char[] { '.', '!', '?' },StringSplitOptions.RemoveEmptyEntries)
- .ToArray();
- Regex regex = new Regex(pattern);
- for (int i = 0; i < sentences.Length; i++)
- {
- Match match = regex.Match(sentences[i]);
- if (match.Success)
- {
- Console.WriteLine(sentences[i].TrimStart());
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment