Created
May 16, 2015 07:14
-
-
Save aanguelov/46fcb4ca787e8653cbc7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Threading.Tasks; | |
namespace SentenceExtractor | |
{ | |
class SentenceExtractor | |
{ | |
static void Main() | |
{ | |
string word = Console.ReadLine(); | |
string text = Console.ReadLine(); | |
string sentencePattern = @"\b[\w\s,`()'-]+[.!?]"; | |
MatchCollection matches = Regex.Matches(text, sentencePattern); | |
foreach (var match in matches) | |
{ | |
if (match.ToString().Split(' ').Contains(word)) | |
{ | |
Console.WriteLine(match); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment