1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Replace comma with tab

Discussion in 'C, C++, C#' started by tsmith2471, Feb 12, 2013.

  1. tsmith2471

    tsmith2471 Newbie

    Joined:
    Oct 21, 2012
    Messages:
    14
    Likes Received:
    4
    I need some help with my program. Write a function that takes a string of comma seperated values and returnd a string of tab seperated values.
    Code:
               String str = new String("Hello, BHW, how, are, you, today?");
            
            str.replaceAll("," , " ");
            
            
    
    
    
    
    
    This is not replacing the comma with a tab. Any suggestions?
     
    Last edited: Feb 12, 2013
  2. Schvamp

    Schvamp Power Member

    Joined:
    Feb 13, 2012
    Messages:
    684
    Likes Received:
    550
    Location:
    Hogwarts
    What languish is it? try: \t
     
  3. tsmith2471

    tsmith2471 Newbie

    Joined:
    Oct 21, 2012
    Messages:
    14
    Likes Received:
    4
    Sorry it was written in Java, but I figured it out

    Code:
    String str1 = new String("Hey,bhw,how,are,you,today?');
    String str2 = str1.replace(',' , ' ');
    
    System.out.println(str2);