private static final Pattern HEXADECIMAL_PATTERN = Pattern.compile("p{XDigit}+"); private boolean isHexadecimal(String input) { final Matcher matcher = HEXADECIMAL_PATTERN.matcher(input); return matcher.matches(); }