Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ExtractSentences
- {
- using System;
- using System.Text.RegularExpressions;
- public class ExtractSentences
- {
- public static void Main(string[] args)
- {
- string text = "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 key = "in";
- for (int i = 0; i < text.Length; i++)
- {
- int currentDotIndex = text.IndexOf(".", i);
- string currentStr = text.Substring(i, currentDotIndex - i + 1);
- if (Regex.IsMatch(currentStr, @"\b" + key + @"\b."))
- {
- Console.WriteLine(currentStr);
- }
- i = currentDotIndex + 1;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement