All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zhuang.data.util.SqlUtils Maven / Gradle / Ivy

There is a newer version: 1.1.2
Show newest version
package com.zhuang.data.util;

import java.util.regex.Pattern;

public class SqlUtils {

    private static Pattern orderByClausePattern = Pattern.compile("[{]\\s*[?]\\s*order\\s+by[\\d|\\w|\\s|$|#|@|:|-|_]*[}]|order\\s+by[\\d|\\w|\\s|$|#|@|:|-|_]*", Pattern.CASE_INSENSITIVE);
    private static Pattern sqlKeyWordPattern = Pattern.compile("select|insert|delete|from", Pattern.CASE_INSENSITIVE);

    public static String removeOrderByClause(String sql) {
        String result;
        result = orderByClausePattern.matcher(sql).replaceAll("");
        return result;
    }

    public static String removeSqlKeyWord(String text)
    {
        return sqlKeyWordPattern.matcher(text).replaceAll("");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy