0
正則表達式是正確的,只是x1
是true
,而它必須是true
只有前x
是\\d
,但在\\d
無需'
之前。我需要較小的字符串作爲number
或'radius
和最大width x height x depth ' radius
無法完成正則表達式
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);
}
是的,但後來我無法鍵入''1',因爲在'''我需要數字之前! – 2013-03-26 09:56:52
我認爲你應該給出一個更完整的解釋你想達到的目的,否則我可以糾正這個匹配也是'1,但我認爲這是不夠的。 – Teudimundo 2013-03-26 09:59:49
我需要我可以放置1個或所有尺寸的項目 - 寬度,高度,深度和半徑... 但項目只能與寬度和高度('1x1')或只有深度('1')或只有半徑(''1'),所以次要的字符串必須是數字或半徑最大的寬度x高度x深度半徑 – 2013-03-26 10:08:30