removing null entries
-
string input = "- plum-pear- tyu"; string pattern = "(-)|( )"; string[] substrings = Regex.Split(input, pattern); // Split on hyphens foreach (string match in substrings) { Console.WriteLine("'{0}'", match); } the above code gives out some null tokens.... how to cleanse it.. pls help
the quieter u become more u hear
-
string input = "- plum-pear- tyu"; string pattern = "(-)|( )"; string[] substrings = Regex.Split(input, pattern); // Split on hyphens foreach (string match in substrings) { Console.WriteLine("'{0}'", match); } the above code gives out some null tokens.... how to cleanse it.. pls help
the quieter u become more u hear
lawrenceinba wrote:
"- plum-pear- tyu";
Do you see the whitespace in the input string (in between - and p & - and t)? You may want to remove it.
string input = "-plum-pear-tyu";
:-)Be careful, there is no Undo Button(Ctrl+Z) in life.
-
lawrenceinba wrote:
"- plum-pear- tyu";
Do you see the whitespace in the input string (in between - and p & - and t)? You may want to remove it.
string input = "-plum-pear-tyu";
:-)Be careful, there is no Undo Button(Ctrl+Z) in life.
no space comes before -
the quieter u become more u hear
-
no space comes before -
the quieter u become more u hear
It looks like it in the code you pasted before. Try this: string[] substrings = Regex.Split(input.Replace(" ", ""), pattern);
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo