代码演示
- maven 依赖:
<!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
- 案例代码:
import org.apache.commons.lang.StringEscapeUtils;
public class Demo {
public static void main(String[] args) {
String a = "hello \\r\\n world";
System.out.println(a);
System.out.println(StringEscapeUtils.unescapeJava(a));
}
}
- 输出结果:
hello \r\n world
hello
world