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

org.mapfish.print.RegexpUtil Maven / Gradle / Ivy

There is a newer version: 3.22.0
Show newest version
package org.mapfish.print;

import java.util.regex.Pattern;

/**
 * Regular Expression utilities.
 */
public final class RegexpUtil {
    private RegexpUtil() {
        // intentionally empty
    }

    /**
     * Convert a string to a Pattern object.
     * 
    *
  • If the host starts and ends with / then it is compiled as a regular expression
  • *
  • Otherwise the hosts must exactly match
  • *
* * @param expr the expression to compile */ public static Pattern compilePattern(final String expr) { Pattern pattern; final int lastChar = expr.length() - 1; if (expr.charAt(0) == '/' && expr.charAt(lastChar) == '/') { pattern = Pattern.compile(expr.substring(1, lastChar)); } else { pattern = Pattern.compile(Pattern.quote(expr)); } return pattern; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy