Removing multiple whitespace, c# -
this question has answer here:
- how trim whitespace between characters 6 answers
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
Post a Comment