Created RegexUtils class to provide commonly used Patterns for User input validation

This commit is contained in:
CrushedPixel
2015-07-25 14:52:25 +02:00
parent 5427616ceb
commit efbf9bd3b9

View File

@@ -0,0 +1,14 @@
package eu.crushedpixel.replaymod.utils;
import java.util.regex.Pattern;
public class RegexUtils {
public static final Pattern ALPHANUMERIC_UNDERSCORE = Pattern.compile("[^a-z0-9_]", Pattern.CASE_INSENSITIVE);
public static final Pattern ALPHANUMERIC_COMMA = Pattern.compile("[^a-z0-9,]", Pattern.CASE_INSENSITIVE);
public static final Pattern ALPHANUMERIC_SPACE_HYPHEN_UNDERSCORE = Pattern.compile("[^a-z0-9 \\-_]", Pattern.CASE_INSENSITIVE);;
public static boolean isValid(Pattern pattern, String string) {
return !pattern.matcher(string).find();
}
}