473,397 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Trim() question

If I apply Trim() method to string consisting of two x0D and x0A characters
the resulting string is not empty but contain the same two charaters: x0D,
x0A.

But according to the help Trim() method
"removes all occurrences of white space characters from the beginning and
end".
And CARRIAGE RETURN (U+000D) and LINE FEED (U+000A) are among
white space characters removed by the Trim() method.

What's wrong ?

Oleg Subachev
Feb 9 '07 #1
4 4070
Trim( new char[] { (char) 0x0A, (char) 0x0D } ) doesn't help also.

Oleg Subachev
Feb 9 '07 #2
On 9 Feb, 10:30, "Oleg Subachev" <o...@urvb.ruwrote:
If I apply Trim() method to string consisting of two x0D and x0A characters
the resulting string is not empty but contain the same two charaters: x0D,
x0A.
Hmmm,

Unless I'm doing something wrong, this seems to work as expected for
me:

string s = new string(new char[] {(char)0x0a,
(char)0x0d });
Console.WriteLine(s.Length);
Console.WriteLine(s.Trim().Length);

i.e. The first length call yields 2, the second 0.

Feb 9 '07 #3
Yes, this was my mistake :-(

Question canceled :-)

Oleg Subachev
Feb 9 '07 #4
If I apply Trim() method to string consisting of two x0D and x0A
characters the resulting string is not empty but contain the same two
charaters: x0D, x0A.

But according to the help Trim() method
"removes all occurrences of white space characters from the beginning
and
end".
And CARRIAGE RETURN (U+000D) and LINE FEED (U+000A) are among
white space characters removed by the Trim() method.
What's wrong ?

Oleg Subachev
How do you "apply that Trim() method"?

If it is something like:
String s = ...
s.Trim();

then it will not work. Trim is a function that returns a new, trimmed string
instead of
trimming the instance it is called on. So:
String s = ...
s = s.Trim();
Hans Kesting
Feb 9 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mikael Hellström | last post by:
Hi all, i need to use the trim function trim("str","?") My question are. How do i remove the "return sign" from a string?? Regards Mikael
36
by: No Spam | last post by:
Dear fellow Access 2003 Users, Is there a way to trim all of the fields in a table in one swoop using VBA (preferred) or a query? Right now, I am using an update query and updating EACH field...
1
by: Gidi | last post by:
hi, how can i take a float number and make it's lengeth to be only 3 or 4 numbers after the points, for example: if i have the number 1.999999999999 i want it to be 1.999 thnaks
6
by: mwazir | last post by:
Can someone please explain this to me Dim str As String = Chr(12) Debug.WriteLine(str) ' Output shows the line feed junk character Dim iLen As Integer = str.Trim.Length...
22
by: Terry Olsen | last post by:
I have an app that makes decisions based on string content. I need to make sure that a string does not contain only spaces or newlines. I am using the syntax 'Trim(String)" and it works fine. I...
10
by: damezumari | last post by:
// trim the parameters foreach($_POST as $varname =$value) {$varname = trim($value);} // give them $p_ prefix import_request_variables('gp', 'p_'); When I do the above the parameters are not...
4
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I trim whitespace - trim/trimRight/trimLeft...
8
by: Kevin Smith | last post by:
Hi, According to the intellisense help, string.Trim() "Removes all occurances or white space characters from the beginning and end of this instance." However, the follow code does not appear...
8
by: Keith Thompson | last post by:
Kevin Smith <no@spam.comwrites: You posted this to microsoft.public.dotnet.languages.csharp, where I presume it's topical. Why on Earth did you redirect followups to comp.lang.c? Anyone...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.