I need this all the time and am constantly frustrated that the Trim(), TrimStart() and TrimEnd() functions don\'t take strings as inputs. You call EndsWith() on a string, an
The following example demonstrates how to extract individual words from a block of text by treating white space and punctuation marks as delimiters. The character array passed to the separator parameter of the String.Split(Char[])
method consists of a space character and a tab character, together with some common punctuation symbols.
string words ="sfdgdfg-121";
string [] split = words.Split(new Char [] {' ', ',', '.', ':', '-' });
foreach (string s in split)
{
if (s.Trim() != "")
Console.WriteLine(s);
}
Try this code.