Removing multiple whitespace, c# -


this question has answer here:

what i'm trying i'm trying reduce whitespace sizes 1 characters (removing unneeded whitespace. how should deal task ?

ps.: no regex

edit.: thanks, succeeded, split+join suggestion. unfortunately, can't upvote of responses frustrated teens have -repspammed me asking "a question simple website"

edit2.: how make sure doesn't remove space in front of sentence, in case there 1 ?

what about

string.join(" ",     mystring.split(new char[] { ' ' }, stringsplitoptions.removeemptyentries)) 

edit

as extension

    public static string removewhitespaces(this string s)     {         return string.join(" ", s.split(new char[] { ' ' },                 stringsplitoptions.removeemptyentries));     } mystring.removewhitespaces(); 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -