I was quickly going through the String class (C#). I found Split and Trim is really handy methods of String class for text processing.
Usually if we call the trim function, it removes the leading and trailing spaces. Here also same, String class provides Trim function for removing leading and trailing spaces. If we need to remove only leading spaces TrimStartand to remove trailing spaces, you can use TrimEndfunction. But Trim method is overloaded to accept a character array, which can trim any of the characters specified in the array appears in the beginning or end of the string. Similarly you can use this function with TrimStart or TrimEnd function. See the sample snippet below
String strHw = "* *_Hello World_* *";
char[] trim = { '*', ' ', '_'};
str = strHw.Trim( trim );
Console.WriteLine("After Trimming:- " + str);
Split method provides painless way for tokenize the string with the given delimiters. No loops or anything required. Just call the Split function and pass the delimiters to spot the end of each tokens. The function will return a string array. This function is really handy especially for things to do like CSV (Comma Seperated values) parsing. The overloaded Split functions gives more control over the return of array( e.g. to return emptry string element or not, maximum string elements to be returned etc). Please check the documentation See the Sample below
String str = "Quick,Brown,Fox,Jumps Over The,Lazy Dog";
Console.WriteLine("String:-" + str + "Split to");
char[] delim = {',', ' '};
String[] csvArray = str.Split(delim);
foreach (String s in csvArray)
{
Console.WriteLine(s);
}