Java 去除字符传中所有不可见字符
时间: 2023-05-21 17:01:04 浏览: 754
可以使用正则表达式来去除字符串中的所有不可见字符,代码如下:
String str = "Hello\u2003World\u2002!";
str = str.replaceAll("\\s+", "");
这里的 "\\s+" 表示匹配一个或多个空白字符,包括空格、制表符、换行符等不可见字符。使用 replaceAll() 方法将匹配到的字符替换为空字符串,即可去除所有不可见字符。
阅读全文
相关推荐
![txt](https://img-home.csdnimg.cn/images/20241231045021.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![txt](https://img-home.csdnimg.cn/images/20241231045021.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![text/x-java](https://img-home.csdnimg.cn/images/20250102104920.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)