|
-
Oct 27th, 2006, 08:44 PM
#1
Thread Starter
Member
[RESOLVED] Removing Spaces
I am reading data in from a text file that has a lot of spacing between fields:
name address phone.
Each column is a fixed length, so if i use substring() i can gather the whole field. The problem is when I use trim() it doesnt remove all the spaces. In debug mode when I go over a variable I will see "name \0\0\0\0\0\0\0\0" "address\0\0\0\0\0" etc. Is there another form of trim() that I can use to remove those. Thanks
-
Oct 27th, 2006, 08:59 PM
#2
Re: Removing Spaces
Are those spaces or null characters? If you call Trim without an argument is will remove spaces only. If you want to remove other characters you have to specify those characters. I suggest that you read the MSDN help topic for the String.Trim method and it will explain.
-
Oct 27th, 2006, 09:18 PM
#3
Thread Starter
Member
Re: Removing Spaces
I actually beleive they are null characters
-
Oct 28th, 2006, 01:35 AM
#4
Re: Removing Spaces
If you're wanting to remove all of the null characters, Trim isn't for you. Trim only removes leading and trailing characters. Use replace:
PHP Code:
string blah = "name \0\0\0\0\0\0\0\0" "address\0\0\0\0\0";
blah = blah.Replace("\0", "");
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Oct 28th, 2006, 09:38 AM
#5
Thread Starter
Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|