该代码总是返回最后“假”,即使整数包含任何零:为什么/ 0/g在包含零的字符串中匹配?
Integer i = (int) rand(1, 200); // random [1;200)
String regexp = "/0/g";
Pattern p = Pattern.compile(regexp);
Matcher m = p.matcher(i.toString());
print(i);
print(m.matches());
的原因是什么?我不知道错误可能在哪里。
需要:m.matches()=“true”如果Integer包含一个或多个零。作为0
输入你的情况是不可能的
对不起语法 – 2015-02-11 13:15:04
什么是/ g? .... – 2015-02-11 13:15:34
嗯,你的正则表达式正在寻找斜线和'g'字符......你期望那些来自哪里? – 2015-02-11 13:15:47