日期:2014-05-20  浏览次数:20755 次

怎么从一个select语句中截取表名
select   *   from                       tableName           where   id   =   "1 ";
像这样一句select语句,如何才能截取到 "tableName "呢?
不一定有where,也许会是order   by

------解决方案--------------------
光字符串处理?
String str = "select * FROM tableName where id = \ "1\ " ";
Pattern wd = Pattern.compile( "(? <=from) +(\\w+).* ",
Pattern.CASE_INSENSITIVE);
Matcher m = wd.matcher(str);
if (m.find()) {
System.out.println(m.group(1));
}