发布网友 发布时间:2022-09-15 10:19
共1个回答
热心网友 时间:2023-10-08 23:54
package ; import java.util.Arrays;import java.util.List; public class Test6{ public static void main ( String[] args ) { String sql = " INSERT INTO TABLE( ID , NAME ,AGE)VALUES( 1 , SS, 18 ) ; "; String reg = "(?i).*into\\s*([^\\((]+)\\s*([\\((][^\\))]+[\\))])\\s*[^\\((]+\\s*([\\((][^\\))]+[\\))]).*"; String A = sql.replaceAll (reg, "$1"); List<String> B = Arrays.asList (sql.replaceAll (reg, "$2").replaceAll ("[\\[\\]\\((\\))\\s]", "").split (",|,")); List<String> C = Arrays.asList (sql.replaceAll (reg, "$3").replaceAll ("[\\[\\]\\((\\))\\s]", "").split (",|,")); System.out.println (A); System.out.println (B); System.out.println (C); }}