java Pattern

public class Test{
//匹配替换掉order by之后的字符串
public static void main(String[] args) {
Pattern pattern = Pattern.compile("order\\s+by\\s+[^,\\s]+(\\s+asc|\\s+desc)?(\\s*,\\s*[^,\\s]+(\\s+asc|\\s+desc)?)*", 10);
System.out.println(pattern.matcher("from dual order by id desc").replaceAll(""));
}

}

  

posted @ 2016-07-15 10:34  N神3  阅读(286)  评论(0编辑  收藏  举报