"Shabam" <blislecp (AT) hotmail (DOT) com> wrote in
news:LtSdncD255eZ2fXcRVn-pQ (AT) adelphia (DOT) com...
Quote:
Is there a function in dotnet that allows me to trim user input so that:
1) It gets rid of leading/trailing spaces, tabs, newlines and whatever
other
non-printing characters |
String.Trim does that - you can tell it what characters to trim, e.g:
myString = myString.Trim(' ', '\t', '\n', '\r');
Quote:
2) Gets rid of all tabs, newlines, and whatever other non-printing
characters anywhere else, preferably replacing them with one space
3) Takes any consecutive number of spaces and replace it with just one
space. |
I'd suggest using a regular expression for that purpose:
myString = System.Text.RegularExpressions.Regex.Replace("\s+" , " ");
Depending on what characters you want to replace you might have to adjust
the search pattern.
Niki