Created
May 2, 2024 14:45
-
-
Save bjoerntx/f89b0cb0105ba4f280018b25d5eaa68e 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
public static List<string> ExtractSentences(string input) | |
{ | |
List<string> sentences = new List<string>(); | |
// Use regular expression to split the input string into sentences but keep white spaces | |
string pattern = @"([.!?])"; | |
// split the input string into sentences with the delimiters | |
string[] splitSentences = Regex.Split(input, pattern); | |
// Trim each sentence and remove empty strings | |
foreach (string sentence in splitSentences) | |
{ | |
sentences.Add(sentence); | |
} | |
return sentences; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment