Created
May 23, 2017 10:08
-
-
Save AntMooreWebDev/9bdfb7fed52a0d17c379fcdc5fcf32ba to your computer and use it in GitHub Desktop.
This returns a list of sentences that contain a specified string.
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
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