problem with string.Trim();

  • Thread starter Thread starter Jeroen Ceuppens
  • Start date Start date
J

Jeroen Ceuppens

Hi, I want to parse a string like "abc abc erer" to "abcabcerer"

=> change white spaces, ..... into nullstring

I tried this code:

char[] trimChars={' ','<','>'};

test=test.Trim(trimChars);

but I don't do what I want :(((( (it doesn't change anything)
Can anybody help?

Thx
Jc
 
"String.Trim Method (Char[]) - Removes all occurrences of a set of
characters specified in an array from the *beginning and end* of this
instance."

Use a Regular Expression.

Ex.

using System.Text;

void foo()
{
RegularExpressions.Regex regTest = new RegularExpressions.Regex(
@"[\s,<>]" );
string test = "abc abc erer<a,b>c";
test = regTest.Replace( test, "" );
}
- K.
 
Back
Top