Replace dash characters in Java strings

See English answers > java string replace not working 6

str.replace("\u2014","");

Can you help me?

Solution

String is immutable in Java You must reassign it to get results:

String str ="your string with dashesh";
str= str.replace("\u2014","");

For more information, see API

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>