[英]Remove special character from string?
我喜歡String
Join our<\/strong>\u00a0<strong>“Worldwide Host Your Own Screening Tour!
而且我要
Join our Worldwide Host Your Own Screening Tour!
我的代碼::
String str = "Join our<\/strong>\u00a0<strong>“Worldwide Host Your";
System.out.println(str.replaceAll("<\/strong>\u00a0<strong>“", " "));
錯誤
Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
嘗試這個:
String str = "Join our<\\/strong>\u00a0<strong>“Worldwide Host Your";
System.out.println(str.replaceAll("<\\\\/strong>\\u00a0<strong>“", " "));
String.replaceAll
需要一個RegEx。
你也可以使用StringUtils (它有點簡單):
StringUtils.replace(str, "<\\/strong>\u00a0<strong>“", "")
試試吧。
String s="Join our<\\/strong>\u00a0<strong>“Worldwide Host Your Own Screening Tour!";
System.out.println(s.replaceAll("<\\\\/strong>\\u00a0<strong>“", " "));
Francisco贏了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.