String str="select * from (select t1.c1,t2.c2 from (select t1.c1,t2.c2 from table1 t1 ))";
while (str.indexOf("select")!=-1) {
int start=str.indexOf("select")+7;
int end=str.indexOf("from")-1;
String out=str.substring(start,end);
System.out.println("OUT:"+out);
str=str.substring(str.indexOf("from")+4);
}
简单测试了一下 应该可以 但是前提是select 和from要配对的 否则就出错咯