Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- class ExtractSentences
- {
- static void Main()
- {
- string text = "In this town. We are living in a yellow submarine. We don't have anything else. Inside the submarine is "
- + "very tight. So we are drinking all the day. We will move out of it in 5 days.";
- string word = "in";
- string[] sentences = text.Split('.');
- for (int i = 0; i < sentences.Length; i++)
- {
- if (Regex.IsMatch(sentences[i], @"\b" + word + @"\b", RegexOptions.IgnoreCase))
- {
- Console.WriteLine((sentences[i] + ".").Trim());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement