我试图用""替换字符串中的所有
但下面似乎没有用。
str.replace(" ","");
我的字符串:
<img alt="" src="abc430.jpg" width="650" height="430" /> u seen <a
href="http://www.funnyordie.com/between_two_ferns" target="_blank"></a> hey hey hey
trying to get this output:
<img alt="" src="abc430.jpg" width="650" height="430" /> u seen <a
href="http://www.funnyordie.com/between_two_ferns" target="_blank"></a>hey hey hey
现在替换代码确实替换了&amp; NBSP;用&#34;&#34;但我的页面输出仍然是
u seen
link here
hey hey
不在一行
答案 0 :(得分:4)
有效。您没有将替换的字符串分配到str
str = str.replace(" ","");
尝试从最终运行此代码:
String str = "alex alex";
str = str.replace(" ","");
System.out.println(str);
输出:
alex alex