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

org.meridor.perspective.sql.PatternUtils Maven / Gradle / Ivy

There is a newer version: 1.3.4.1
Show newest version
package org.meridor.perspective.sql;

import java.util.regex.Pattern;

public final class PatternUtils {

    public static boolean isExactMatch(String expression) {
        return expression != null && expression.startsWith("^") && expression.endsWith("$");
    }

    public static boolean isContainsMatch(String expression) {
        return expression != null && expression.startsWith("%") && expression.endsWith("%");
    }

    public static boolean isRegex(String expression) {
        try {
            Pattern.compile(expression);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
    
    public static String removeFirstAndLastChars(String expression) {
        if (expression == null || expression.length() < 2) {
            return expression;
        }
        return expression.substring(1, expression.length() - 1);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy