0

我有类似的字符串

Join our<\/strong>\u00a0<strong>&#8220;Worldwide Host Your Own Screening Tour!

而且我要

Join our Worldwide Host Your Own Screening Tour!

我的代码::

String str = "Join our<\/strong>\u00a0<strong>&#8220;Worldwide Host Your";
System.out.println(str.replaceAll("<\/strong>\u00a0<strong>&#8220;", " "));

错误

 Invalid escape sequence (valid ones are  \b  \t  \n  \f  \r  \"  \'  \\ )
4

2 回答 2

1

尝试这个:

String str = "Join our<\\/strong>\u00a0<strong>&#8220;Worldwide Host Your";
System.out.println(str.replaceAll("<\\\\/strong>\\u00a0<strong>&#8220;", " "));

String.replaceAll需要一个正则表达式。

您也可以使用StringUtils(这有点简单):

StringUtils.replace(str, "<\\/strong>\u00a0<strong>&#8220;", "")
于 2012-07-12T13:39:19.830 回答
1

试试看。

    String s="Join our<\\/strong>\u00a0<strong>&#8220;Worldwide Host Your Own Screening Tour!";
    System.out.println(s.replaceAll("<\\\\/strong>\\u00a0<strong>&#8220;", " "));

弗朗西斯科获胜。

于 2012-07-12T13:43:50.327 回答