473,396 Members | 1,655 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,396 software developers and data experts.

how to trim off trailing spaces and or commas from a string - thankyou

In my continuing education regarding string manipulation,

can someone advise me how to take any trailing spaces, and commas from
a string.

these strings are comming from the streamreader

for instance.

string 1 = 'abcd '
string 2 = 'abc,'

and i want the string mapped to string1 to read 'abcd'
and the string mapped to string2 to read 'abc'

Many Thanks,

Gary.

May 2 '06 #1
3 1893
myString.TrimEnd(' ',',')

Marc
May 2 '06 #2
try this:
string MyString = " abc ,";

MyString = MyString.Trim(' ', ',');

Console.WriteLine("The answer is '{0}'", MyString);


<ga********@myway.com> a écrit dans le message de news:
11**********************@v46g2000cwv.googlegroups. com...
In my continuing education regarding string manipulation,

can someone advise me how to take any trailing spaces, and commas from
a string.

these strings are comming from the streamreader

for instance.

string 1 = 'abcd '
string 2 = 'abc,'

and i want the string mapped to string1 to read 'abcd'
and the string mapped to string2 to read 'abc'

Many Thanks,

Gary.

May 2 '06 #3
Thankyou both that's exactly what i wanted.

it never ceases to amaze me how much functionality is built into the
Libraries as standard.

Thanks,

Gary.

May 2 '06 #4

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

Similar topics

8
by: DrBob | last post by:
gcc 3.3 MAC OS X. I have a string that has trailing spaces in it that I want removed. So i have a variable: string x("abcd "); x.trim() isn't an implemented method. Is there a method I...
5
by: Alex Vassiliev | last post by:
Hi all. Just wanted to share two handy RegEx expressions to strips leading and trailing white-space from a string, and to replace all repeated spaces, newlines and tabs with a single space. *...
3
by: Andy B | last post by:
I've tried using Trim or RTrim to strip trailing space characters from my data. When I check on the transformed data space characters are still there. We have an address table containing two...
5
by: Tammy | last post by:
I am doing some genealogy research and I have discovered that there is a lot of data available on the web in text format. The problem is that the columns in the files are lined up by spaces. I'd...
9
by: Durgesh Sharma | last post by:
Hi All, Pleas help me .I am a starter as far as C Language is concerned . How can i Right Trim all the white spaces of a very long (2000 chars) Charecter string ( from the Right Side ) ? or how...
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...
7
by: Sascha Herpers | last post by:
Hi, what is the difference between the trim function and the trim String-member? As far as I see it, both return the trimmed string and leave the original string unaltered. Is any of the two...
7
by: Henri | last post by:
Hello, any idea why a regexp-based trim function would work fine in firefox but not in ie? code is String.prototype.trim = function() { re = /\s*$/g; return this.replace(re, "");
121
by: swengineer001 | last post by:
Just looking for a few eyes on this code other than my own. void TrimCString(char *str) { // Trim whitespace from beginning: size_t i = 0; size_t j; while(isspace(str)) {
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.