Well, you CAN use regex for this, but I would say that it is a bit of an overkill.
The best use for regex here would be to remove all possible non-hex characters from the string with:
String hexStr = subjectString.replaceAll("[^0-9A-Fa-f]", "");
Anyway, here's how you could convert the hex string into plain ASCII:
With RegEx:
StringBuilder output = new StringBuilder("");
Pattern regex = Pattern.compile("[0-9A-Fa-f]{2}");
Matcher regexMatcher = regex.matcher(hexStr);
while (regexMatcher.find()) {
output.append((char) Integer.parseInt(regexMatcher.group(), 16));
}
output.toString();
Without RegEx:
StringBuilder output = new StringBuilder("");
for (int i = 0; i < hexStr.length(); i += 2) {
String str = hexStr.substring(i, i + 2);
output.append((char) Integer.parseInt(str, 16));
}
output.toString();