Skip to content

Instantly share code, notes, and snippets.

@AntMooreWebDev
Created May 23, 2017 10:08
Show Gist options
  • Save AntMooreWebDev/9bdfb7fed52a0d17c379fcdc5fcf32ba to your computer and use it in GitHub Desktop.
Save AntMooreWebDev/9bdfb7fed52a0d17c379fcdc5fcf32ba to your computer and use it in GitHub Desktop.
This returns a list of sentences that contain a specified string.
public static List<String> SentenceExtractor(this string text, string word)
{
var sentences = text.Split(new[] { ". " }, StringSplitOptions.RemoveEmptyEntries);
var matches = from sentence in sentences
where sentence.ToLower().Contains(word.ToLower())
select sentence;
return matches.ToList();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment