要处理字符串
Medical Care ( Costs Inverse ## agonism ( Costs Inverse ## agonism ) ) Costs ( Inverse ## agonism ) at beta_1 ##adrenergic receptors
替换操作:将字符串中 所有括号 内的 ##替换成 @
处理结果:
Medical Care ( Costs Inverse @ agonism ( Costs Inverse @ agonism ) ) Costs ( Inverse @ agonism ) at beta_1 ## adrenergic receptors
各路高手帮帮忙 ( 正则表达式或者其它方法都行的 )
public static void main(String[] args) {
String s = "Medical Care ( Costs Inverse ## agonism ( Costs Inverse ## agonism ) ) Costs ( Inverse ## agonism ) at beta_1 ##adrenergic receptors";
String returnValue = "";
String [] str = s.split("\\)");
for (int i = 0; i < str.length; i++) {
if(" ".equals(str[i])){
str[i] = ")";
}
if(str[i].contains("(")){
str[i] = str[i].replaceAll("##", "@@")+")";
}
}
s = ArrayUtils.toString(str).replace(",", " ");
returnValue = s.substring(1, s.length()-1);
System.out.println(returnValue);
}