比如一个字符串," 安 卓开 发第 一 章 hellow world";
String str =" 安 卓开 发第 一 章 hellow world";
Log.d("替换前:", str);
str= str.replaceAll("([A-Za-z-]) +([A-Za-z-])","$1@$2");
str= str.replaceAll("\\s+","").replaceAll("@"," ");
Log.d("替换后:" , str);
比如一个字符串," 安 卓开 发第 一 章 hellow world";
String str =" 安 卓开 发第 一 章 hellow world";
Log.d("替换前:", str);
str= str.replaceAll("([A-Za-z-]) +([A-Za-z-])","$1@$2");
str= str.replaceAll("\\s+","").replaceAll("@"," ");
Log.d("替换后:" , str);