org.mapfish.print.RegexpUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of print-lib Show documentation
Show all versions of print-lib Show documentation
Library for generating PDFs and images from online webmapping services
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