1 //帶有特殊符號字符串示例 2 String str = "我的名字(測試)"; 3 4 //去除特殊字符內容 其中的“()”為特殊字符 5 str.replaceAll("[^0-9a-zA-Z\u4e00-\u9fa5.,,。?“”]+",""); 6 7 //去除特殊符號后字符串內容: 8 System.out.println("字符串str:" + str");// str:我的名字測試
1 //帶有特殊符號字符串示例 2 String str = "我的名字(測試)"; 3 4 //去除特殊字符內容 其中的“()”為特殊字符 5 str.replaceAll("[^0-9a-zA-Z\u4e00-\u9fa5.,,。?“”]+",""); 6 7 //去除特殊符號后字符串內容: 8 System.out.println("字符串str:" + str");// str:我的名字測試
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。