Search code examples
javaregexstringreplacespecial-characters

Replace special character from String


I have a String str =\'abc\' which I am printing. Its printing like \'abc'\ instead of 'abc'.

I have tried this option: str.replaceAll("\\", ""); but its giving me java.util.regex.PatternSyntaxException: Unexpected internal error near index 1

Can anyone help resolve this issue.


Solution

  • i think you mean :

    public class Abc {

    public static void main(String[] args) {
    
    
        String str ="\'abc\'";
    
        System.out.println(str);
    
    }
    

    }

    output : 'abc'

    it is coming correct for me.