【发布时间】:2012-12-27 21:33:07
【问题描述】:
我正在尝试从包含引号中的文本 "matchup" 的字符串中删除子字符串。要删除的完整子字符串类似于To get an in-depth statistical preview, click "matchup" at the top of the screen。
我正在尝试做一个
string.replace("To get an in-depth statistical preview, click "matchup" at the top of the screen", "");
这会将那个长句子替换为空白;然而,由于“matchup”在字符串中实际上有引号,当我将它作为参数传入时,它会吓坏并认为我有两个单独的字符串,它们之间有一些随机的文本matchup。
对不起,如果这很难理解,我可能做得不好。我也试过做
...'matchup'.... rather than ..."matchup"...
它似乎不起作用。
【问题讨论】:
-
转义“这样的\”
-
如果这是 Java 代码,您的示例甚至无法编译。你确定
java标签在这里合适吗?