lundi 20 août 2018

Need to get parameters alone from query as arraylist return parameter

I have written program which will take Query as input and to get parameters alone as arraylist return (used Regex patern Split) (OUTPUT) but i am getting with () also if we added like its also coming. ****Input**** SELECT * FROM some_table WHERE some_column1 = ‘%(some_parameter_1)%’ and some_column2=’%(some_parameter_2)%’ and some_column3=’%(some_parameter_3)%’; output n array list containing the following elements in it: some_parameter_1 some_parameter_2

some_parameter_3

String patternString = "%";
    Pattern pattern = Pattern.compile(patternString);

    String[] split = pattern.split(query);

    System.out.println("split.length = " + split.length);

    for(String element : split){
        System.out.println("element = " + element);
        a1.add(element);
    }

    int n = a1.size();
    for(int j =1;j <= n; j=j+2){
        params.add(a1.get(j));
    }
    System.out.println("\n List of Parameters  "+params);
    /* for(int j =1;j <= 7; j=+1)
    System.out.println(a1.get(j)); */
    return params;
}

kindly help me to use match.result in regex thats not getting effect it seems .. any other way to solve I need the parameter alone enclosed in %(some-param1)% as a arraylist return

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire