需要修复正则表达式以匹配任何尺寸组合(宽度 x 高度 x 深度'半径):例如
'100
100
或100'100
100x100
或100x100'100
100x100x100
或100x100x100'100
checkField = "x1";
String r = "\\d{0,4}(x\\d{1,4}){0,2}('\\d{1,4})?";
Pattern p = Pattern.compile(r);
Matcher m = p.matcher(checkField);
String a = String.valueOf(m.matches());
if (m.matches()) {
infoBox(checkField, a);
} else {
errorBox(checkField, a);
}