【发布时间】:2013-08-27 17:03:17
【问题描述】:
如果我有一个字符串变量:
String example = "Hello, I'm here";
我想在每个' 和" 变量内前面添加一个转义字符(即不是实际上转义字符),如何我这样做?
【问题讨论】:
-
你的意思是在编辑器中?
-
只需输入 \ 字符?
-
使用来自 apache commons 的 StringEscapeUtils.html#escapeJava
-
我的意思是使用
example变量。 -
example.replace("'", "\\'");