i need to replace or remove the single double quote in my string.
For ex:- Data"list should be Datalist.
Please let me know the solution .
            Asked
            
        
        
            Active
            
        
            Viewed 47 times
        
    -4
            
            
        - 
                    @khelwood this is not a duplicate of a python question. – f1sh Feb 04 '19 at 10:32
- 
                    @f1sh Quite right. I picked the wrong dupe. This one instead: [Remove all occurrences of char from string](https://stackoverflow.com/questions/4576352/remove-all-occurrences-of-char-from-string) – khelwood Feb 04 '19 at 10:33
- 
                    @AsierAranbarri the double quote must be escaped. – Santhosh Arun Feb 04 '19 at 10:34
- 
                    @khelwood I suspect the problem is about escaping the `"`, not the actual replacement – f1sh Feb 04 '19 at 10:34
- 
                    1@f1sh That's why people should include their attempts. – khelwood Feb 04 '19 at 10:34
- 
                    1@SanthoshArun not if you use single quotes around it, which makes this a `char`. But in that case the second argument has to be a char too. – f1sh Feb 04 '19 at 10:35
- 
                    @khelwood I agree. Hence the "suspect" :) – f1sh Feb 04 '19 at 10:36
- 
                    @f1sh and also the second char must not be left empty, it must be '\0'(null) – Santhosh Arun Feb 04 '19 at 10:37
- 
                    1@SanthoshArun Then you would end up with a `\0` in the middle of your string. – khelwood Feb 04 '19 at 10:39
- 
                    @SanthoshArun your should NOT use the `\0` char in a java String, especially if you insert it into the middle of the String. You need to replace it with an empty String, see my answer below. – f1sh Feb 04 '19 at 10:39
- 
                    @f1sh I said them for char, not for String. character cannot be empty. – Santhosh Arun Feb 04 '19 at 10:41
- 
                    I forgot the scape syntax...sorry for that. – aran Feb 04 '19 at 10:42
- 
                    @SanthoshArun but you recommended using the `'\0'` char, which is wrong. – f1sh Feb 04 '19 at 10:42
- 
                    @f1sh yes you are right, that would leave a space. – Santhosh Arun Feb 04 '19 at 10:43
- 
                    1@SanthoshArun No, it would leave a `\0`. That's different from a space. – khelwood Feb 04 '19 at 10:43
- 
                    ok i accept that it is null on screen – Santhosh Arun Feb 04 '19 at 10:44
1 Answers
0
            
            
        Use replace. You need to escape the " since it's used in java as a delimeter to String literals:
String newString = oldString.replace("\"", "");
 
    
    
        f1sh
        
- 11,489
- 3
- 25
- 51
- 
                    i guess this is to replace pair of double quotes i.e Data""list, but in my case it is Data"list. – Aaliya Feb 04 '19 at 12:17
- 
                    What makes you think this replaces double quotes? Have you tried it? Do you understand what `\"` means? Why do you "guess"? – f1sh Feb 04 '19 at 12:24
