Created
October 19, 2010 06:00
-
-
Save prabirshrestha/633691 to your computer and use it in GitHub Desktop.
Remove Whitespace with split
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
// http://www.aspdotnetfaq.com/Faq/How-to-remove-duplicate-Whitespace-Characters-from-a-string.aspx | |
public static string RemoveWhitespaceWithSplit(string inputString) | |
{ | |
StringBuilder sb = new StringBuilder(); | |
string[] parts = inputString.Split(new [] { ' ', '\n', '\t', '\r', '\f', '\v' }, StringSplitOptions.RemoveEmptyEntries); | |
int size = parts.Length; | |
for (int i = 0; i < size; i++) | |
sb.AppendFormat("{0} ", parts[i]); | |
return sb.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment