Judge if the specified querying string contain GROUP BY statement - Java java.lang

Java examples for java.lang:String Contain

Description

Judge if the specified querying string contain GROUP BY statement

Demo Code

//package com.java2s;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] argv) {
        String ql = "java2s.com group          by";
        System.out.println(containsGroupByStatement(ql));
    }//from w  w w  . j ava 2 s.c om

    /**
     * Judge if the specified querying string contain GROUP BY statement
     * 
     * @param ql
     */
    public static boolean containsGroupByStatement(String ql) {
        String regEx = "group[\\s]+by";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(ql.toLowerCase());
        return m.find();
    }
}

Related Tutorials