Write a function that takes a string and split it by words to array of strings.
static void Main(string[] args)
{
// Example of program usage
string text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut\nlabore et dolore magna aliqua. Ut enim ad minim veniam...";
string[] words = Split(text);
foreach(string s in words)
{
Console.WriteLine(s);
}
Console.ReadKey();
}
// Split method
public static string [] Split(string text)
{
string[] separatingStrings = { " ", ",", ".", ":", "\t", "\n" };
return text.Split(separatingStrings, System.StringSplitOptions.RemoveEmptyEntries);
}
Comments
Leave a comment