How to insert backslash into my string in java?
java, string
Solution
Try like this
engData.replace("'", "\\\'");
INPUT : can't
EXPECTED OUTPUT : can\'t
Problem
I have string, and I want to replace one of its character with backslash \ I tried the following, but no luck. ``` engData.replace("'t", "\\'t") ``` and ``` engData = engData.replace("'t", String.copyValueOf(new char[]{'\\', 't'})); ``` INPUT : "can't" EXPECTED OUTPUT : "can\'t" Any idea how to do this?