String split方法在忽略參數(shù)大小的情況下取得String[]的小技巧
摘要: select * from tableA union select * from tableB
要根據(jù)關(guān)鍵字把兩個(gè)查詢語句分解出來,即得到
select * from tableA 和 select * from tableB
但因?yàn)檫@個(gè)是SQL語句,union關(guān)鍵字不區(qū)分大小寫的,所有sql語句有這些情況:
select * from tableA UNION select * from tableB
select * from tableA UnIOn select * from tableB
select * from tableA UNiON select * from tableB
……
所以單單用這樣的語句:String sql2[]=sql.split(" union ");
是分解不出子語句的。
閱讀全文