日期:2014-05-18 浏览次数:20858 次
String url = "CSDN论坛(研发(牛人)论坛地图)";
String tmp = url.replaceAll("\\([^\\)]*\\)", "")
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class StringSplite {
public String work(String word){
String regex = "\\([\\u4e00-\\u9fa5]*\\)";
String wordTmp = "";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(word);
if(m.find()){
// System.out.println(m.group());
wordTmp = word.replace(m.group(), "");
}else{
return word;
}
return work(wordTmp);
}
public static void main(String[] args) {
String word = "CSDN论坛(研发(牛人)论坛(牛人)地图)";
StringSplite ss = new StringSplite();
System.out.println(ss.work(word));
}
}
String regex = "\\([\\S]*\\)";