Advertisement
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 _2.Extract_sentences_by_keyword
- {
- class Program
- {
- static void Main(string[] args)
- {
- string word = Console.ReadLine();
- string text = Console.ReadLine();
- string pattern = @"(?:^|[\s|\w]+) word [a-zA-Z0-9]+[\sa-z-0-9]+";
- var replaced = pattern.Replace("word", word);
- var reg = new Regex(replaced);
- MatchCollection matchCollection = reg.Matches(text);
- foreach (Match match in matchCollection)
- {
- Console.WriteLine(match.Groups[0]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement