How to unescape a Java string literal in Java?

后端 未结 11 1809
庸人自扰
庸人自扰 2020-11-22 01:35

I\'m processing some Java source code using Java. I\'m extracting the string literals and feeding them to a function taking a String. The problem is that I need to pass the

11条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 02:37

    Java 13 added a method which does this: String#translateEscapes.

    It was a preview feature in Java 13 and 14, but was promoted to a full feature in Java 15.

提交回复
热议问题