473,811 Members | 2,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Find last comma in string

Hello,

I need to replace the last comma in a string by " and ". How can I do
this?

Thanks,
Miguel
Nov 22 '08 #1
3 5013
On Fri, 21 Nov 2008 15:57:26 -0800, shapper <md*****@gmail. comwrote:
Hello,

I need to replace the last comma in a string by " and ". How can I do
this?
http://msdn.microsoft.com/en-us/libr...stindexof.aspx

That link will help you solve the first half of the problem. I leave it
as an exercise for you to solve the second half, but I'll provide a hint:
generally speaking, if you want to know what you can do with an instance
of String, you should look at the "Class Members" documentation page on
MSDN. Often you will find that there is already method to accomplish your
goal or, at the very least, one that would be helpful.

You could have answered the first half of this question by using that
hint, and you should be able to answer the second half by doing so as well.

Pete
Nov 22 '08 #2
"shapper" <md*****@gmail. comwrote in message
news:df******** *************** ***********@33g 2000yqm.googleg roups.com...
I need to replace the last comma in a string by " and ". How can I do
this?
http://msdn.microsoft.com/en-us/libr...stindexof.aspx
http://msdn.microsoft.com/en-us/library/aka44szs.aspx
http://msdn.microsoft.com/en-us/libr...g.replace.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 22 '08 #3
"shapper" <md*****@gmail. comwrote in message
news:df******** *************** ***********@33g 2000yqm.googleg roups.com...
Hello,

I need to replace the last comma in a string by " and ". How can I do
this?

Thanks,
Miguel

Does your list potentially contain currency strings? If so, I hope that one
of your test strings is "$3,000.00, $4,000.00, $5,000.00".

Nov 22 '08 #4

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

Similar topics

9
26177
by: PaulThomas | last post by:
I want to "look" through a comma delimited String and "take it apart" by finding the comma's and then put each "set of characters" into seperate strings - - - maybe an array, maybe seperate cells in a table -or- whatever... Can anyone help me locate the commands (samples) that might do this? Actually, I want to read a file and use these comma seperated groups of data to "load" a database and this comma seperated data is the individual...
1
4967
by: jcabc | last post by:
I have a text string which has multiple values seperated by commas. My goal is to find the postion of the 4th comma and then read the text after that comma until the next comma using VBA. Ex. One, Two, Three, Four, Five, Six Valued wanted: " Five" Is there any way to do this??
32
4161
by: James Curran | last post by:
I'd like to make the following proposal for a new feature for the C# language. I have no connection with the C# team at Microsoft. I'm posting it here to gather input to refine it, in an "open Source" manner, and in an attempt to build a ground-swell of support to convince the folks at Microsoft to add it. Proposal: "first:" "last:" sections in a "foreach" block The problem: The foreach statement allows iterating over all the...
9
4515
by: Wayne | last post by:
I have the following string: "smith", "Joe", "West Palm Beach, Fl." I need to split this string based on the commas, but as you see the city state contains a comma. String.split will spilt the city state. Is there a built in function that I'm missing that will do the split and recognize that the comma in city state is part of the item? --
2
45275
by: ad | last post by:
I have a string variable lik: sList="1.Tiger, 2.Wolf, 3.Rabbit," I want to trim off the last character "," Have there pre-define function to do that?
5
3969
by: Denis Petronenko | last post by:
Hello, for(int i=0; i<100; ++i){ cout << i << ","; } // how can i remove last comma here? ...... cout << endl;
13
1916
by: SuvarnaChaudhari | last post by:
Hi,I am new to .net. As per ur guidance I tried myString = myString.SubString(0,myString.Length-1); I also used str.lastindexof n str.remove,but by using this I m gettin string as ' (B193 '' H13 '' H14 ' ) instead of (' B193 ',' H13 ',' H14' ).My original string is (' B193 ',' H13 ',' H14 ', )I want to remove last comma.My code is --- Dim s1, strpid As String Dim arr(), arr2() Dim i As Integer s1 =...
4
4339
anfetienne
by: anfetienne | last post by:
hi im back again.......i have a code to create strings and save it within a text file to pass variables to flash. im using the string format below. mylist=apple,cherry,lemon,banana&mylist2=apple,cherry,lemon,banana this code below is what im using to write my string to the text file, basically the info is collected from a db and i use a loop to cycle through and write each value in. I have to seperate these values using a comma ','...
0
10644
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10379
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10393
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10124
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.