Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace _02.ExtractSentencesByKeyWord
- {
- class ExtractSentencesByKeyWord
- {
- static void Main()
- {
- string word = Console.ReadLine();
- Regex pattern = new Regex($@"\b[^.?!]+\b {word} \b[^.?!]+\b");
- string text = Console.ReadLine();
- MatchCollection matches = pattern.Matches(text);
- foreach (Match match in matches)
- {
- string sentence = match.Value.Trim();
- Console.WriteLine(sentence);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement