Connecting Tech Pros Worldwide Help | Site Map

Find last comma in string

  #1  
Old November 22nd, 2008, 12:05 AM
shapper
Guest
 
Posts: n/a
Hello,

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

Thanks,
Miguel
  #2  
Old November 22nd, 2008, 12:35 AM
Peter Duniho
Guest
 
Posts: n/a

re: Find last comma in string


On Fri, 21 Nov 2008 15:57:26 -0800, shapper <mdmoura@gmail.comwrote:
Quote:
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
  #3  
Old November 22nd, 2008, 12:35 AM
Mark Rae [MVP]
Guest
 
Posts: n/a

re: Find last comma in string


"shapper" <mdmoura@gmail.comwrote in message
news:df9dc6f8-44d7-4b1b-8773-1e37cf197310@33g2000yqm.googlegroups.com...
Quote:
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

  #4  
Old November 22nd, 2008, 12:45 AM
Family Tree Mike
Guest
 
Posts: n/a

re: Find last comma in string


"shapper" <mdmoura@gmail.comwrote in message
news:df9dc6f8-44d7-4b1b-8773-1e37cf197310@33g2000yqm.googlegroups.com...
Quote:
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".

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
String shapper answers 2 September 11th, 2007 10:35 PM
How to Parse a File in C AdrianH insights 0 June 4th, 2007 06:02 PM
regex in python gisleyt answers 3 May 25th, 2006 01:35 PM
structure in Python Alberto Vera answers 27 July 18th, 2005 05:14 AM