【发布时间】:2014-04-08 11:44:34
【问题描述】:
我的字符串也包含一些特殊字符和空格。我想删除空格和特殊字符,我正在这样做
String str = "45,%$^ Sharma%$&^,is,46&* a$# java#$43 Developer$#$^ in#$^ CST&^* web*&(,but He%^&^% want to move@!$@# in another team";
System.out.println( str.replaceAll("[^a-zA-Z]", " ").replaceAll("\\s+"," "));
Output :- sharma is a java Developer in CST web but He want to move in another team
我可以使用单个操作来做到这一点吗?怎么样?
【问题讨论】: