[英]How to remove the \n, \t and spaces between the strings in java?
如何刪除java中字符串之間的\\ n,\\ t和空格?
str.replaceAll("\\s+", "");
\\ s一個空格字符:[\\ t \\ n \\ x0B \\ f \\ r \\ n]
java.util.regex.Pattern
具有所有預定義的類。
將String.replaceAll與正則表達式一起使用以刪除所有空格:
s = s.replaceAll("\\s+", "");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.